2016-09-22 02:33:09 +00:00
From 639ec1035a1b282d21b9ba6e112039d6a0995c13 Mon Sep 17 00:00:00 2001
2016-03-18 05:35:26 +00:00
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
2016-09-22 02:33:09 +00:00
index e6e7626..854fbd7 100644
2016-03-18 05:35:26 +00:00
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
2016-06-12 17:00:07 +00:00
@@ -174,11 +174,16 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
2016-03-18 05:35:26 +00:00
NBTTagCompound nbttagcompound = chunk.compound; // Paper - Chunk queue improvements
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
2016-03-18 05:35:26 +00:00
}
synchronized (lock) { if (this.b.get(chunkcoordintpair) == nbttagcompound) { 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
2016-06-16 23:22:35 +00:00
index c9bd856..1fe5019 100644
2016-03-18 05:35:26 +00:00
--- a/src/main/java/net/minecraft/server/RegionFile.java
+++ b/src/main/java/net/minecraft/server/RegionFile.java
2016-06-16 23:22:35 +00:00
@@ -246,8 +246,7 @@ public class RegionFile {
2016-03-18 05:35:26 +00:00
this.b(i, j, (int) (MinecraftServer.av() / 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
}
}
--
2016-09-22 02:33:09 +00:00
2.9.3
2016-03-18 05:35:26 +00:00