Minecraft的疑难杂症#9-Watching Server/服务器卡顿滞后过久使Watchdog自动关闭服务器
感谢在粉丝群里分享的这篇崩溃日志和服务器日志w,我就拿来用啦。别问我为什么突然复活,只是在放寒假(
这个崩溃应该是在1.14加入一个Server Watchdog(服务器看门狗)引起的,这是一个线程,当有滞后(Lag)过久时它就会自动结束服务器进程。
由于这个崩溃是因为服务器滞后/卡顿造成的,因此具有一定的随机性,这取决于你的服务器在什么时候出现了滞后以及滞后的程度。

(一)崩溃日志
---- Minecraft Crash Report ----
Description: Watching Server
java.lang.Error: Watchdog
at java.base@17.0.2/java.lang.ClassLoader.defineClass1(Native Method)
at java.base@17.0.2/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
at java.base@17.0.2/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base@17.0.2/java.net.URLClassLoader.defineClass(URLClassLoader.java:524)
at java.base@17.0.2/java.net.URLClassLoader$1.run(URLClassLoader.java:427)
at java.base@17.0.2/java.net.URLClassLoader$1.run(URLClassLoader.java:421)
at java.base@17.0.2/java.security.AccessController.executePrivileged(AccessController.java:807)
at java.base@17.0.2/java.security.AccessController.doPrivileged(AccessController.java:712)
at java.base@17.0.2/java.net.URLClassLoader.findClass(URLClassLoader.java:420)
at java.base@17.0.2/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
at java.base@17.0.2/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at sh.a(SourceFile:26)
at ahn.b(SourceFile:1372)
at akr.a(SourceFile:801)
at akr.a(SourceFile:793)
at aif.a(SourceFile:1232)
at sb.m(SourceFile:425)
at aie.c(SourceFile:196)
at net.minecraft.server.MinecraftServer.b(SourceFile:897)
at agn.b(SourceFile:283)
at net.minecraft.server.MinecraftServer.a(SourceFile:830)
at net.minecraft.server.MinecraftServer.w(SourceFile:676)
at net.minecraft.server.MinecraftServer.a(SourceFile:264)
at net.minecraft.server.MinecraftServer$$Lambda$4384/0x000000080149ef90.run(Unknown Source)
at java.base@17.0.2/java.lang.Thread.run(Thread.java:833)
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- Head --
Thread: Server Watchdog
Stacktrace:
at java.base@17.0.2/java.lang.ClassLoader.defineClass1(Native Method)
at java.base@17.0.2/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
-- Thread Dump --
Details:
Threads: "Reference Handler" daemon prio=10 Id=2 RUNNABLE
at java.base@17.0.2/java.lang.ref.Reference.waitForReferencePendingList(Native Method)
at java.base@17.0.2/java.lang.ref.Reference.processPendingReferences(Reference.java:253)
at java.base@17.0.2/java.lang.ref.Reference$ReferenceHandler.run(Reference.java:215)
[省略...]
[省略守护进程 ...]
[省略...]
[省略Stacktrace...]
-- [省略Performance stats...] --
-- System Details --
Details:
Minecraft Version: 1.19.3
Minecraft Version ID: 1.19.3
Operating System: Windows 10 (amd64) version 10.0
[省略...]
Memory: 573078016 bytes (546 MiB) / 1649410048 bytes (1573 MiB) up to 2147483648 bytes (2048 MiB)
[省略...]
Is Modded: Probably not. Server jar signature and brand is untouched
Type: Dedicated Server (map_server.txt)
(二)Logs文件夹下的日志/服务器日志,注意加粗字
[之前省略...]
[21:33:50] [Server thread/INFO]: *** joined the game
[21:34:08] [Server thread/INFO]: [Not Secure] <*> 阿伟你坐标报一下
[21:35:08] [Server Watchdog/ERROR]: A single server tick took 60.00 seconds (should be max 0.05)
[21:39:55] [Server thread/WARN]: Can't keep up! Is the server overloaded? Running 346606ms or 6932 ticks behind
[21:39:55] [Server Watchdog/ERROR]: Considering it to be crashed, server will forcibly shutdown.(Watchdog认为服务器已经崩溃,将对其强制关闭。)
[21:39:59] [Server thread/INFO]: *** lost connection: Disconnected
[21:39:59] [Server thread/INFO]: *** left the game
[21:39:59] [Server thread/INFO]: ** lost connection: Disconnected
[21:39:59] [Server thread/INFO]: ** left the game
[21:39:59] [Server thread/INFO]: com.mojang.authlib.GameProfile@4ba487ed[id=<null>,name=***,properties={},legacy=false] (/***.***.**.**:*****) lost connection: Disconnected
[省略……]
[21:39:59] [Server thread/INFO]: com.mojang.authlib.GameProfile@2ec83d36[id=<null>,name=*,properties={},legacy=false] (/*) lost connection: Disconnected
[21:39:59] [Server Watchdog/ERROR]: This crash report has been saved to: J:\*\.\crash-reports\crash-2023-01-13_21.39.59-server.txt
以上两篇日志均做了部分删减和修改,以节省篇幅和保护隐私
解决方案:
1. 将Watchdog滞后自动关闭设置到更久一点或关闭它。
在服务器文件目录下,你应该能找到server.properties文件,用文本编辑器之类的软件打开它,将里面的max-tick-time后面的数值修改成比60000还大的数字(滞后更久再关闭服务器,该数字以毫秒为单位,默认滞后60秒自动关闭服务器)或者是-1(不检测滞后,该选项在14w32a中添加)。
2. 自行提防服务器会引起卡顿的内容并做好相关处理措施。
3. 提升你服务器的运行内存。
相关链接:
[MC-63590] Watchdog shuts down server - Jira (https://bugs.mojang.com/browse/MC-63590)

最后再说:
虽然在之前的文章里面没有有目的地请你们帮忙点个赞(虽然我也不怎么在乎赞嘎嘎嘎,能帮到就好),但是我发现如果赞少的话会影响文章的推广,不怎么利于及时帮助其他有相似问题的玩家,所以还是希望如果这篇或其它文章对你有用的话,麻烦请你点个赞喵,谢谢辣w