2020-05-06 11:48:49 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2016-03-18 06:35:26 +01: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
2020-05-06 11:48:49 +02:00
index c2312a227c60417c02fc028047e1e4562bbfccff..cee1ea8f43e3135cd72a67c1c8067174feaf956e 100644
2016-03-18 06:35:26 +01:00
--- a/src/main/java/net/minecraft/server/RegionFile.java
+++ b/src/main/java/net/minecraft/server/RegionFile.java
2019-12-13 17:29:51 +01:00
@@ -241,7 +241,7 @@ public class RegionFile implements AutoCloseable {
2019-12-11 03:43:21 +01:00
return true;
}
} catch (IOException ioexception) {
- com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(ioexception); // Paper
+ com.destroystokyo.paper.util.SneakyThrow.sneaky(ioexception); // Paper - we want the upper try/catch to retry this
return false;
}
2016-03-18 06:35:26 +01:00
}
2018-08-26 20:11:49 +02:00
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
2020-05-06 11:48:49 +02:00
index a164aee8805580069cc4b6daee7f2ad9137d34e0..fd46da95e0342c0004d82a36a164f3a18f9edac6 100644
2018-08-26 20:11:49 +02:00
--- a/src/main/java/net/minecraft/server/RegionFileCache.java
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
2020-04-27 09:34:45 +02:00
@@ -85,6 +85,7 @@ public final class RegionFileCache implements AutoCloseable {
2018-08-26 20:11:49 +02:00
2019-04-26 03:24:00 +02:00
protected void write(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) throws IOException {
2019-12-11 03:43:21 +01:00
RegionFile regionfile = this.getFile(chunkcoordintpair, false); // CraftBukkit
2018-08-26 20:11:49 +02:00
+ int attempts = 0; Exception laste = null; while (attempts++ < 5) { try { // Paper
2019-04-26 03:24:00 +02:00
DataOutputStream dataoutputstream = regionfile.c(chunkcoordintpair);
Throwable throwable = null;
2019-12-11 03:43:21 +01:00
2020-04-27 09:34:45 +02:00
@@ -108,6 +109,18 @@ public final class RegionFileCache implements AutoCloseable {
2019-04-26 03:24:00 +02:00
}
2018-08-26 20:11:49 +02:00
2019-05-07 17:26:37 +02:00
+ // Paper start
+ return;
2019-04-26 03:24:00 +02:00
+ } catch (Exception ex) {
+ laste = ex;
+ }
2018-08-26 20:11:49 +02:00
+ }
2019-04-26 03:24:00 +02:00
+
2018-08-26 20:11:49 +02:00
+ if (laste != null) {
+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(laste);
+ MinecraftServer.LOGGER.error("Failed to save chunk", laste);
+ }
2019-05-07 17:26:37 +02:00
+ // Paper end
2018-08-26 20:11:49 +02:00
}
2019-04-26 03:24:00 +02:00
public void close() throws IOException {