13
0
geforkt von Mirrors/Paper
Paper/patches/server/0060-Chunk-Save-Reattempt.patch

52 Zeilen
2.6 KiB
Diff

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
2021-11-23 13:15:10 +01:00
index 9f3223947d2fcc1aaf259effe6afce7a47888858..7b69007609ed421ee72ddc3d6f2a7b64888babf1 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
2021-11-23 13:15:10 +01:00
@@ -274,7 +274,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
2021-11-23 13:15:10 +01:00
index 8ba1c073387fa21a20bd42a873ec3cc314eae64e..eaf22cec54b512e0f57606f50627d5fe9b39bd5c 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
2021-11-23 13:15:10 +01:00
@@ -131,6 +131,7 @@ public class RegionFileStorage implements AutoCloseable {
2021-06-11 14:02:28 +02:00
2021-06-12 02:57:04 +02:00
protected void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException {
2021-11-23 13:15:10 +01:00
RegionFile regionfile = this.getRegionFile(pos, false); // CraftBukkit
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);
2021-11-23 13:15:10 +01:00
@@ -156,6 +157,18 @@ public class RegionFileStorage implements AutoCloseable {
2021-06-12 02:57:04 +02:00
}
2021-06-11 14:02:28 +02:00
}
+ // Paper start
+ return;
+ } catch (Exception ex) {
+ laste = ex;
+ }
+ }
+
+ if (laste != null) {
+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(laste);
2021-11-23 13:15:10 +01:00
+ net.minecraft.server.MinecraftServer.LOGGER.error("Failed to save chunk", laste);
2021-06-11 14:02:28 +02:00
+ }
+ // Paper end
}
public void close() throws IOException {