Paper/Spigot-Server-Patches/0078-Chunk-Save-Reattempt.patch

47 Zeilen
2.6 KiB
Diff

2016-05-12 04:07:46 +02:00
From 0e0ec1d44114445a752f0a8fcee7a5e44fcf20d8 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
2016-05-12 04:07:46 +02:00
index a5c4e95..be0a565 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
2016-05-12 04:07:46 +02:00
@@ -172,11 +172,16 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
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
+ if (laste != null) { com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(laste); laste.printStackTrace(); } // Paper
}
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-03-25 02:23:23 +01:00
index 2ca94a4..68dd17d 100644
--- a/src/main/java/net/minecraft/server/RegionFile.java
+++ b/src/main/java/net/minecraft/server/RegionFile.java
2016-03-25 02:23:23 +01:00
@@ -247,8 +247,7 @@ public class RegionFile {
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-05-12 04:07:46 +02:00
2.8.2