2019-06-14 02:27:40 +00:00
From 1eeb11e8a032025ea4bf2cd1e9b2b977138cc33f 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/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java
2019-06-06 15:36:57 +00:00
index 88b5aa3a51..b062a31c49 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
2019-04-26 01:24:00 +00:00
@@ -253,8 +253,7 @@ public class RegionFile implements AutoCloseable {
2016-03-18 05:35:26 +00:00
2019-04-26 01:24:00 +00:00
this.b(chunkcoordintpair, (int) (SystemUtils.getTimeMillis() / 1000L));
2016-03-18 05:35:26 +00:00
} catch (IOException ioexception) {
- ioexception.printStackTrace();
- ServerInternalException.reportInternalException(ioexception); // Paper
2019-01-06 17:15:21 +00:00
+ com.destroystokyo.paper.util.SneakyThrow.sneaky(ioexception); // Paper - we want the upper try/catch to retry this
2016-03-18 05:35:26 +00:00
}
}
2018-08-26 18:11:49 +00:00
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
2019-06-06 15:36:57 +00:00
index 84fe9ee3bf..1ea9e5bb43 100644
2018-08-26 18:11:49 +00:00
--- a/src/main/java/net/minecraft/server/RegionFileCache.java
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
2019-04-26 01:24:00 +00:00
@@ -79,6 +79,7 @@ public abstract class RegionFileCache implements AutoCloseable {
}
2018-08-26 18:11:49 +00:00
2019-04-26 01:24:00 +00:00
protected void write(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) throws IOException {
2018-08-26 18:11:49 +00:00
+ int attempts = 0; Exception laste = null; while (attempts++ < 5) { try { // Paper
2019-04-26 01:24:00 +00:00
RegionFile regionfile = this.a(chunkcoordintpair, false); // CraftBukkit
DataOutputStream dataoutputstream = regionfile.c(chunkcoordintpair);
Throwable throwable = null;
2019-05-07 15:26:37 +00:00
@@ -103,6 +104,18 @@ public abstract class RegionFileCache implements AutoCloseable {
2019-04-26 01:24:00 +00:00
}
2018-08-26 18:11:49 +00:00
2019-05-07 15:26:37 +00:00
+ // Paper start
+ return;
2019-04-26 01:24:00 +00:00
+ } catch (Exception ex) {
+ laste = ex;
+ }
2018-08-26 18:11:49 +00:00
+ }
2019-04-26 01:24:00 +00:00
+
2018-08-26 18:11:49 +00:00
+ if (laste != null) {
+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(laste);
+ MinecraftServer.LOGGER.error("Failed to save chunk", laste);
+ }
2019-05-07 15:26:37 +00:00
+ // Paper end
2018-08-26 18:11:49 +00:00
}
2019-04-26 01:24:00 +00:00
public void close() throws IOException {
2016-03-18 05:35:26 +00:00
--
2019-04-23 04:47:07 +00:00
2.21.0
2016-03-18 05:35:26 +00:00