13
0
geforkt von Mirrors/Paper
Paper/patches/server/0063-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
2023-09-21 22:14:58 +02:00
index 67a2f3c02aa4983b3ec2df073821190ddb36543c..9e65b56fd2d5af6be305efa08e7c569e6598343a 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-21 22:14:58 +02: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
2023-09-21 22:14:58 +02:00
index 216f527334a5ee5007633ede6abfc0abe3e0e829..8fc4eb15732536c5f8c49c7914071d3c7667f340 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-21 22:14:58 +02:00
@@ -132,6 +132,7 @@ public final class RegionFileStorage implements AutoCloseable {
protected void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException {
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);
2023-09-21 22:14:58 +02:00
@@ -156,7 +157,18 @@ public final 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-21 22:14:58 +02:00
}
public void close() throws IOException {