PaperMC/patches/server/0064-Chunk-Save-Reattempt.patch

52 lines
2.6 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 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/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
2023-09-23 00:33:14 +02:00
index ab9681ba3a86212e0e23a9af8788eec1dbee36ab..2a7f17726a161ddbcd0397fb4332de6980199c38 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
2023-09-22 22:13:57 +02:00
@@ -275,7 +275,7 @@ public class RegionFile implements AutoCloseable {
2021-06-11 14:02:28 +02: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;
}
}
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
2023-09-22 22:13:57 +02:00
index 2b6ba2e30c9a4682d6deb2ab750d6923ad8469e4..2d00333f25828ef5912c925d1213a56c564d85c9 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
2023-09-22 22:13:57 +02:00
@@ -209,6 +209,7 @@ public class RegionFileStorage implements AutoCloseable {
}
// Paper end - rewrite chunk system
try { // Paper
2021-06-11 14:02:28 +02:00
+ int attempts = 0; Exception laste = null; while (attempts++ < 5) { try { // Paper
2021-06-12 02:57:04 +02:00
if (nbt == null) {
regionfile.clear(pos);
2023-09-22 22:13:57 +02:00
@@ -233,7 +234,18 @@ public class RegionFileStorage implements AutoCloseable {
dataoutputstream.close();
2021-06-12 02:57:04 +02:00
}
2021-06-11 14:02:28 +02:00
}
+ // Paper start
+ return;
2021-06-11 14:02:28 +02:00
+ } catch (Exception ex) {
+ laste = ex;
+ }
+ }
2021-06-11 14:02:28 +02:00
+ if (laste != null) {
+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(laste);
+ net.minecraft.server.MinecraftServer.LOGGER.error("Failed to save chunk " + pos, laste);
2021-06-11 14:02:28 +02:00
+ }
+ // Paper end
2023-09-22 22:13:57 +02:00
} finally { // Paper start
regionfile.fileLock.unlock();
} // Paper end