diff options
author | Spottedleaf <[email protected]> | 2022-03-05 17:29:47 -0800 |
---|---|---|
committer | Spottedleaf <[email protected]> | 2022-03-05 17:29:47 -0800 |
commit | 196271de4e38896c410526dfa9cfa28c041fd7ed (patch) | |
tree | 0da02bec11c23734c99cf62423c2ca4aee4ef5d1 | |
parent | 6564f70f4c569e46f3320c284b4fead197fccd05 (diff) | |
download | Paper-196271de4e38896c410526dfa9cfa28c041fd7ed.tar.gz Paper-196271de4e38896c410526dfa9cfa28c041fd7ed.zip |
Fix save problems on shutdown
- Save level.dat first, in case the shutdown is killed later
- Force run minecraftserver tasks and the chunk source tasks
while waiting for the chunk system to empty, as there's simply
too much trash that could prevent them from executing during
the chunk source tick (i.e "time left in tick" logic).
-rw-r--r-- | patches/server/0878-Fix-deadlock-on-watchdog-crash.patch | 21 | ||||
-rw-r--r-- | patches/server/0878-Fix-falling-block-spawn-methods.patch (renamed from patches/server/0879-Fix-falling-block-spawn-methods.patch) | 0 | ||||
-rw-r--r-- | patches/server/0879-Expose-furnace-minecart-push-values.patch (renamed from patches/server/0880-Expose-furnace-minecart-push-values.patch) | 0 | ||||
-rw-r--r-- | patches/server/0880-Fix-cancelling-ProjectileHitEvent-for-piercing-arrow.patch (renamed from patches/server/0881-Fix-cancelling-ProjectileHitEvent-for-piercing-arrow.patch) | 0 | ||||
-rw-r--r-- | patches/server/0881-Fix-save-problems-on-shutdown.patch | 59 |
5 files changed, 59 insertions, 21 deletions
diff --git a/patches/server/0878-Fix-deadlock-on-watchdog-crash.patch b/patches/server/0878-Fix-deadlock-on-watchdog-crash.patch deleted file mode 100644 index 7839535587..0000000000 --- a/patches/server/0878-Fix-deadlock-on-watchdog-crash.patch +++ /dev/null @@ -1,21 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jason Penilla <[email protected]> -Date: Fri, 4 Mar 2022 00:12:49 -0700 -Subject: [PATCH] Fix deadlock on watchdog crash - -The watchdog thread sets MinecraftServer#forceTicks to true which will -cause waitUntilNextTick to hang when the task queue is drained. - -diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 17e87875a95495940899b862eabf98b3d6a365da..07c382f30ed3736ed15b5b71f48dc4a1de958242 100644 ---- a/src/main/java/net/minecraft/server/MinecraftServer.java -+++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1012,7 +1012,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa - }, false); - } - -- this.waitUntilNextTick(); -+ this.managedBlock(() -> !this.canSleepForTickNoOversleep() || this.getPendingTasksCount() == 0); // Paper - based on waitUntilNextTick - } - - this.saveAllChunks(false, true, false); diff --git a/patches/server/0879-Fix-falling-block-spawn-methods.patch b/patches/server/0878-Fix-falling-block-spawn-methods.patch index 5ff117ee09..5ff117ee09 100644 --- a/patches/server/0879-Fix-falling-block-spawn-methods.patch +++ b/patches/server/0878-Fix-falling-block-spawn-methods.patch diff --git a/patches/server/0880-Expose-furnace-minecart-push-values.patch b/patches/server/0879-Expose-furnace-minecart-push-values.patch index 4086d94249..4086d94249 100644 --- a/patches/server/0880-Expose-furnace-minecart-push-values.patch +++ b/patches/server/0879-Expose-furnace-minecart-push-values.patch diff --git a/patches/server/0881-Fix-cancelling-ProjectileHitEvent-for-piercing-arrow.patch b/patches/server/0880-Fix-cancelling-ProjectileHitEvent-for-piercing-arrow.patch index b95d6ace5a..b95d6ace5a 100644 --- a/patches/server/0881-Fix-cancelling-ProjectileHitEvent-for-piercing-arrow.patch +++ b/patches/server/0880-Fix-cancelling-ProjectileHitEvent-for-piercing-arrow.patch diff --git a/patches/server/0881-Fix-save-problems-on-shutdown.patch b/patches/server/0881-Fix-save-problems-on-shutdown.patch new file mode 100644 index 0000000000..bb39b0fdd8 --- /dev/null +++ b/patches/server/0881-Fix-save-problems-on-shutdown.patch @@ -0,0 +1,59 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Spottedleaf <[email protected]> +Date: Sat, 5 Mar 2022 17:12:52 -0800 +Subject: [PATCH] Fix save problems on shutdown + +- Save level.dat first, in case the shutdown is killed later +- Force run minecraftserver tasks and the chunk source tasks + while waiting for the chunk system to empty, as there's simply + too much trash that could prevent them from executing during + the chunk source tick (i.e "time left in tick" logic). + +diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java +index 17e87875a95495940899b862eabf98b3d6a365da..e25c9a9ccab67a018c2e58e13b24089bc2ce538f 100644 +--- a/src/main/java/net/minecraft/server/MinecraftServer.java ++++ b/src/main/java/net/minecraft/server/MinecraftServer.java +@@ -998,6 +998,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa + } + } + ++ // Paper start - let's be a little more intelligent around crashes ++ // make sure level.dat saves ++ for (ServerLevel level : this.getAllLevels()) { ++ level.saveLevelDat(); ++ } ++ // Paper end - let's be a little more intelligent around crashes ++ + while (this.levels.values().stream().anyMatch((worldserver1) -> { + return worldserver1.getChunkSource().chunkMap.hasWork(); + })) { +@@ -1010,9 +1017,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa + worldserver.getChunkSource().tick(() -> { + return true; + }, false); ++ while (worldserver.getChunkSource().pollTask()); // Paper - drain tasks + } + +- this.waitUntilNextTick(); ++ while (this.pollTask()); // Paper - drain tasks + } + + this.saveAllChunks(false, true, false); +diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java +index b5b56d4549e97abbbe9e91d881b9bca8428f1eec..dce7452d58d6081f1a83baddafb1596ebd423d21 100644 +--- a/src/main/java/net/minecraft/server/level/ServerLevel.java ++++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +@@ -1258,7 +1258,13 @@ public class ServerLevel extends Level implements WorldGenLevel { + } + + } ++ // Paper start ++ this.saveLevelDat(); ++ } + ++ public void saveLevelDat() { ++ this.saveLevelData(); ++ // Paper end + // CraftBukkit start - moved from MinecraftServer.saveChunks + ServerLevel worldserver1 = this; + |