testserver/Spigot-Server-Patches/0066-Chunk-Save-Reattempt.p...

47 lines
2.5 KiB
Diff
Raw Normal View History

2018-01-11 05:31:19 +00:00
From 8aa4fd3f27fff342a97065ddfbe6c143ccf91f55 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 4 Mar 2013 23:46:10 -0500
Subject: [PATCH] Chunk Save Reattempt
We commonly have "Stream Closed" errors on chunk saving, so this code should re-try to save the chunk in the event of failure and hopefully prevent rollbacks.
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
2018-01-11 05:31:19 +00:00
index 4c3faa20..12bd558a 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
2017-08-12 21:32:01 +00:00
@@ -194,11 +194,16 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
// CraftBukkit
if (nbttagcompound != null) {
+ int attempts = 0; Exception laste = null; while (attempts++ < 5) { // Paper
try {
this.b(chunkcoordintpair, nbttagcompound);
+ laste = null; break; // Paper
} catch (Exception exception) {
- ChunkRegionLoader.a.error("Failed to save chunk", exception);
+ //ChunkRegionLoader.a.error("Failed to save chunk", exception); // Paper
+ laste = exception; // Paper
}
+ try {Thread.sleep(10);} catch (InterruptedException e) {e.printStackTrace();} } // Paper
2016-09-22 02:33:09 +00:00
+ if (laste != null) { com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(laste); MinecraftServer.LOGGER.error("Failed to save chunk", laste); } // Paper
}
2017-08-12 21:32:01 +00:00
synchronized (lock) { if (this.b.get(chunkcoordintpair) == chunk.compoundSupplier) { this.b.remove(chunkcoordintpair); } }// Paper - This will not equal if a newer version is still pending
diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java
2018-01-11 05:31:19 +00:00
index 6a92b5af..5bcbd718 100644
--- a/src/main/java/net/minecraft/server/RegionFile.java
+++ b/src/main/java/net/minecraft/server/RegionFile.java
2017-04-29 00:25:52 +00:00
@@ -210,8 +210,7 @@ public class RegionFile {
2016-11-17 02:23:38 +00:00
this.b(i, j, (int) (MinecraftServer.aw() / 1000L));
} catch (IOException ioexception) {
- ioexception.printStackTrace();
- ServerInternalException.reportInternalException(ioexception); // Paper
+ org.spigotmc.SneakyThrow.sneaky(ioexception); // Paper - we want the upper try/catch to retry this
}
}
--
2018-01-11 05:31:19 +00:00
2.14.3