diff options
author | Aikar <[email protected]> | 2020-07-28 22:19:01 -0400 |
---|---|---|
committer | Aikar <[email protected]> | 2020-07-28 22:22:46 -0400 |
commit | 0d19e4579b2f4a16713da2f19c629ee02ba61f4b (patch) | |
tree | 8e065a2a90862ee3c559b034d866bcceb0015f35 | |
parent | baf1fabe9ee7e904f8fbafa2ac577e1e4f90befd (diff) | |
download | Paper-0d19e4579b2f4a16713da2f19c629ee02ba61f4b.tar.gz Paper-0d19e4579b2f4a16713da2f19c629ee02ba61f4b.zip |
Fix deadlock issue with watchdog stopping
Fixes #4008
4 files changed, 32 insertions, 36 deletions
diff --git a/Spigot-Server-Patches/0447-Improved-Watchdog-Support.patch b/Spigot-Server-Patches/0447-Improved-Watchdog-Support.patch index 142043bdb6..09bd2265e8 100644 --- a/Spigot-Server-Patches/0447-Improved-Watchdog-Support.patch +++ b/Spigot-Server-Patches/0447-Improved-Watchdog-Support.patch @@ -109,7 +109,7 @@ index 63fdae15ccbef0c39718b320dbd096794bcfa3b4..6beefff203ed6e448898eb5b2e95800d } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 04eb2af28f9843ef7641f5464d2a043c696de864..d9ed9df3021dab1f5ee0a51215a002253ac1e34c 100644 +index 04eb2af28f9843ef7641f5464d2a043c696de864..fb65978d783a91b341658e0ebe393ab77153a0d9 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -159,7 +159,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas @@ -138,31 +138,27 @@ index 04eb2af28f9843ef7641f5464d2a043c696de864..d9ed9df3021dab1f5ee0a51215a00225 private final Object stopLock = new Object(); public final boolean hasStopped() { synchronized (stopLock) { -@@ -749,10 +752,22 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas - // CraftBukkit start - prevent double stopping on multiple threads - synchronized(stopLock) { +@@ -751,6 +754,19 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas if (hasStopped) return; -+ shutdownThread = Thread.currentThread(); hasStopped = true; -+ org.spigotmc.WatchdogThread.doStop(); // Paper -+ // Paper start - kill main thread, and kill it hard -+ if (!isMainThread()) { -+ while (this.getThread().isAlive()) { -+ this.getThread().stop(); -+ try { -+ Thread.sleep(1); -+ } catch (InterruptedException e) {} -+ } -+ } -+ // Paper end } ++ // Paper start - kill main thread, and kill it hard ++ shutdownThread = Thread.currentThread(); ++ org.spigotmc.WatchdogThread.doStop(); // Paper ++ if (!isMainThread()) { ++ MinecraftServer.LOGGER.info("Stopping main thread (Ignore any thread death message you see! - DO NOT REPORT THREAD DEATH TO PAPER)"); ++ while (this.getThread().isAlive()) { ++ this.getThread().stop(); ++ try { ++ Thread.sleep(1); ++ } catch (InterruptedException e) {} ++ } ++ } ++ // Paper end // CraftBukkit end -- MinecraftServer.LOGGER.info("Stopping server"); -+ MinecraftServer.LOGGER.info("Stopping server (Ignore any thread death message you see! - DO NOT REPORT THREAD DEATH TO PAPER)"); // Paper + MinecraftServer.LOGGER.info("Stopping server"); MinecraftTimings.stopServer(); // Paper - // CraftBukkit start - if (this.server != null) { -@@ -816,7 +831,18 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas +@@ -816,7 +832,18 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas this.getUserCache().c(false); // Paper } // Spigot end @@ -181,7 +177,7 @@ index 04eb2af28f9843ef7641f5464d2a043c696de864..d9ed9df3021dab1f5ee0a51215a00225 } public String getServerIp() { -@@ -909,6 +935,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas +@@ -909,6 +936,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas protected void v() { try { @@ -189,7 +185,7 @@ index 04eb2af28f9843ef7641f5464d2a043c696de864..d9ed9df3021dab1f5ee0a51215a00225 if (this.init()) { this.nextTick = SystemUtils.getMonotonicMillis(); this.serverPing.setMOTD(new ChatComponentText(this.motd)); -@@ -916,6 +943,18 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas +@@ -916,6 +944,18 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas this.a(this.serverPing); // Spigot start @@ -208,7 +204,7 @@ index 04eb2af28f9843ef7641f5464d2a043c696de864..d9ed9df3021dab1f5ee0a51215a00225 org.spigotmc.WatchdogThread.hasStarted = true; // Paper Arrays.fill( recentTps, 20 ); long start = System.nanoTime(), curTime, tickSection = start; // Paper - Further improve server tick loop -@@ -971,6 +1010,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas +@@ -971,6 +1011,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas this.a((CrashReport) null); } } catch (Throwable throwable) { @@ -221,7 +217,7 @@ index 04eb2af28f9843ef7641f5464d2a043c696de864..d9ed9df3021dab1f5ee0a51215a00225 MinecraftServer.LOGGER.error("Encountered an unexpected exception", throwable); // Spigot Start if ( throwable.getCause() != null ) -@@ -1002,14 +1047,14 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas +@@ -1002,14 +1048,14 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas } catch (Throwable throwable1) { MinecraftServer.LOGGER.error("Exception stopping the server", throwable1); } finally { @@ -239,7 +235,7 @@ index 04eb2af28f9843ef7641f5464d2a043c696de864..d9ed9df3021dab1f5ee0a51215a00225 } } -@@ -1065,6 +1110,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas +@@ -1065,6 +1111,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas @Override protected TickTask postToMainThread(Runnable runnable) { @@ -252,7 +248,7 @@ index 04eb2af28f9843ef7641f5464d2a043c696de864..d9ed9df3021dab1f5ee0a51215a00225 return new TickTask(this.ticks, runnable); } -@@ -1307,6 +1358,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas +@@ -1307,6 +1359,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas try { crashreport = CrashReport.a(throwable, "Exception ticking world"); } catch (Throwable t) { @@ -260,7 +256,7 @@ index 04eb2af28f9843ef7641f5464d2a043c696de864..d9ed9df3021dab1f5ee0a51215a00225 throw new RuntimeException("Error generating crash report", t); } // Spigot End -@@ -1757,7 +1809,8 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas +@@ -1757,7 +1810,8 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas this.resourcePackRepository.a(collection); this.saveData.a(a(this.resourcePackRepository)); datapackresources.i(); @@ -271,7 +267,7 @@ index 04eb2af28f9843ef7641f5464d2a043c696de864..d9ed9df3021dab1f5ee0a51215a00225 this.customFunctionData.a(this.dataPackResources.a()); this.ak.a(this.dataPackResources.h()); diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index c31e7c977194c953a47f5f04d9f90442a88e2db3..6e7754588960a1e6ceacc8b4cfd8237a10e210bb 100644 +index d95ef14f5a4babc8c8fff349baf6a9aa44edcc82..1fcf75b2ed3c8c1ca2e31f679fc7d507f963caf2 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -486,6 +486,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { diff --git a/Spigot-Server-Patches/0478-Use-distance-map-to-optimise-entity-tracker.patch b/Spigot-Server-Patches/0478-Use-distance-map-to-optimise-entity-tracker.patch index 843379b430..96251a29bd 100644 --- a/Spigot-Server-Patches/0478-Use-distance-map-to-optimise-entity-tracker.patch +++ b/Spigot-Server-Patches/0478-Use-distance-map-to-optimise-entity-tracker.patch @@ -44,10 +44,10 @@ index 9b89c0c8a3f1dada4e9b2aaeed0b92e56229b7ca..0c46297e6ff229538d77b2f481e4ab13 List<Entity> list = this.tracker.getPassengers(); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index d9ed9df3021dab1f5ee0a51215a002253ac1e34c..b32d41fac5f855e302469209f368c3674b849fe3 100644 +index fb65978d783a91b341658e0ebe393ab77153a0d9..752ef8c1f99c6ef224e4df0c544f7894c2b3d3ab 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1526,6 +1526,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas +@@ -1527,6 +1527,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas } } diff --git a/Spigot-Server-Patches/0488-Wait-for-Async-Tasks-during-shutdown.patch b/Spigot-Server-Patches/0488-Wait-for-Async-Tasks-during-shutdown.patch index 2810cdbc53..d37ec7f0f7 100644 --- a/Spigot-Server-Patches/0488-Wait-for-Async-Tasks-during-shutdown.patch +++ b/Spigot-Server-Patches/0488-Wait-for-Async-Tasks-during-shutdown.patch @@ -10,10 +10,10 @@ Adds a 5 second grace period for any async tasks to finish and warns if any are still running after that delay just as reload does. diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index b32d41fac5f855e302469209f368c3674b849fe3..7c1c929819c450f853c91618b2853fcb424caa22 100644 +index 752ef8c1f99c6ef224e4df0c544f7894c2b3d3ab..aaea027a3c3f6797e2c763f0ae7159e2d431049e 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -772,6 +772,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas +@@ -773,6 +773,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas // CraftBukkit start if (this.server != null) { this.server.disablePlugins(); diff --git a/Spigot-Server-Patches/0522-Fix-Per-World-Difficulty-Remembering-Difficulty.patch b/Spigot-Server-Patches/0522-Fix-Per-World-Difficulty-Remembering-Difficulty.patch index c53afcca97..26aa3daa08 100644 --- a/Spigot-Server-Patches/0522-Fix-Per-World-Difficulty-Remembering-Difficulty.patch +++ b/Spigot-Server-Patches/0522-Fix-Per-World-Difficulty-Remembering-Difficulty.patch @@ -39,10 +39,10 @@ index 4c561181a977fd0244325880bb6a8cd6a54dcacc..8b2755a3b95e472e884976195d1d3551 @Override diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 7c1c929819c450f853c91618b2853fcb424caa22..26f230a801bd8efa5f8b61dee53fe7b1435f906b 100644 +index aaea027a3c3f6797e2c763f0ae7159e2d431049e..67a6fc68c6611dab2a3617d5605d7a9e7d9bee2a 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1519,11 +1519,14 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas +@@ -1520,11 +1520,14 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas this.H = keypair; } @@ -63,7 +63,7 @@ index 7c1c929819c450f853c91618b2853fcb424caa22..26f230a801bd8efa5f8b61dee53fe7b1 } diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index 4a99a05ef2d01383553e59833a8723f5364168ed..cf83059fec9f11df992827f0c0249243caa9ac33 100644 +index 999ab59d1efc095029baea4d4101eb9b2f80347f..1cc16c20ca03902c3e871a7ec19fab442253da27 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -2780,7 +2780,7 @@ public class PlayerConnection implements PacketListenerPlayIn { |