Co-authored-by: Bjarne Koll <git@lynxplay.dev>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
Co-authored-by: MiniDigger | Martin <admin@minidigger.dev>
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
Co-authored-by: Noah van der Aa <ndvdaa@gmail.com>
Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
Co-authored-by: Tamion <70228790+notTamion@users.noreply.github.com>
Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com>
This commit is contained in:
Nassim Jahnke
2025-04-12 17:26:44 +02:00
parent 0767902699
commit f00727c57e
2092 changed files with 50551 additions and 48729 deletions
@@ -18,8 +18,8 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre
private long timeoutTime;
private boolean restart;
private final long earlyWarningEvery; // Paper - Timeout time for just printing a dump but not restarting
private final long earlyWarningDelay; // Paper
public static volatile boolean hasStarted; // Paper
private final long earlyWarningDelay;
public static volatile boolean hasStarted;
private long lastEarlyWarning; // Paper - Keep track of short dump times to avoid spamming console with short dumps
private volatile long lastTick;
private volatile boolean stopping;
@@ -28,8 +28,8 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre
super("Paper Watchdog Thread");
this.timeoutTime = timeoutTime;
this.restart = restart;
this.earlyWarningEvery = Math.min(GlobalConfiguration.get().watchdog.earlyWarningEvery, timeoutTime); // Paper
this.earlyWarningDelay = Math.min(GlobalConfiguration.get().watchdog.earlyWarningDelay, timeoutTime); // Paper
this.earlyWarningEvery = Math.min(GlobalConfiguration.get().watchdog.earlyWarningEvery, timeoutTime);
this.earlyWarningDelay = Math.min(GlobalConfiguration.get().watchdog.earlyWarningDelay, timeoutTime);
}
private static long monotonicMillis() {
@@ -38,7 +38,7 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre
public static void doStart(int timeoutTime, boolean restart) {
if (WatchdogThread.instance == null) {
if (timeoutTime <= 0) timeoutTime = 300; // Paper
if (timeoutTime <= 0) timeoutTime = 300;
WatchdogThread.instance = new WatchdogThread(timeoutTime * 1000L, restart);
WatchdogThread.instance.start();
} else {
@@ -60,7 +60,6 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre
@Override
public void run() {
while (!this.stopping) {
// Paper start
Logger logger = Bukkit.getServer().getLogger();
long currentTime = WatchdogThread.monotonicMillis();
MinecraftServer server = MinecraftServer.getServer();
@@ -75,7 +74,6 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre
continue; // Don't spam early watchdog warnings during shutdown, we'll come back to this...
this.lastEarlyWarning = currentTime;
if (isLongTimeout) {
// Paper end
logger.log(Level.SEVERE, "------------------------------");
logger.log(Level.SEVERE, "The server has stopped responding! This is (probably) not a Paper bug."); // Paper
logger.log(Level.SEVERE, "If you see a plugin in the Server thread dump below, then please report it to that author");
@@ -129,12 +127,11 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre
if (isLongTimeout) {
if (!server.hasStopped()) {
AsyncCatcher.enabled = false; // Disable async catcher incase it interferes with us
server.forceTicks = true;
if (this.restart) {
RestartCommand.addShutdownHook(SpigotConfig.restartScript);
}
// try one last chance to safe shutdown on main incase it 'comes back'
// try one last chance to safe shutdown on main in case it 'comes back'
server.abnormalExit = true;
server.safeShutdown(false, this.restart);
try {
@@ -159,24 +156,24 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre
}
}
private static void dumpThread(ThreadInfo thread, Logger log) {
log.log(Level.SEVERE, "------------------------------");
private static void dumpThread(ThreadInfo thread, Logger logger) {
logger.log(Level.SEVERE, "------------------------------");
log.log(Level.SEVERE, "Current Thread: " + thread.getThreadName());
log.log(Level.SEVERE, "\tPID: " + thread.getThreadId()
logger.log(Level.SEVERE, "Current Thread: " + thread.getThreadName());
logger.log(Level.SEVERE, "\tPID: " + thread.getThreadId()
+ " | Suspended: " + thread.isSuspended()
+ " | Native: " + thread.isInNative()
+ " | State: " + thread.getThreadState());
if (thread.getLockedMonitors().length != 0) {
log.log(Level.SEVERE, "\tThread is waiting on monitor(s):");
logger.log(Level.SEVERE, "\tThread is waiting on monitor(s):");
for (MonitorInfo monitor : thread.getLockedMonitors()) {
log.log(Level.SEVERE, "\t\tLocked on:" + monitor.getLockedStackFrame());
logger.log(Level.SEVERE, "\t\tLocked on:" + monitor.getLockedStackFrame());
}
}
log.log(Level.SEVERE, "\tStack:");
logger.log(Level.SEVERE, "\tStack:");
for (StackTraceElement stack : io.papermc.paper.util.StacktraceDeobfuscator.INSTANCE.deobfuscateStacktrace(thread.getStackTrace())) { // Paper
log.log(Level.SEVERE, "\t\t" + stack);
logger.log(Level.SEVERE, "\t\t" + stack);
}
}
}