Paper/Spigot-Server-Patches/0063-Chunk-Save-Reattempt.patch
Aikar 835bc39b03
Paper 1.13.1 Update
Updated Upstream (Bukkit/CraftBukkit/Spigot)

Bukkit Changes:
2dcc44dc SPIGOT-4307: Fix hacky API for banners on shields
e0fc6572 SPIGOT-4309: Add "forced" display of particles
efeeab2f Add index to README.md for easier navigation
f502bc6f Update to Minecraft 1.13.1

CraftBukkit Changes:
d0bb0a1d Fix some tests randomly failing
997d378d Fix client stall in specific teleportation scenarios
b3dc2366 SPIGOT-4307: Fix hacky API for banners on shields
2a271162 SPIGOT-4301: Fix more invalid enchants
5d0d83bb SPIGOT-4309: Add "forced" display of particles
a6772578 Add additional tests for CraftBlockData
ce1af0c3 Update to Minecraft 1.13.1

Spigot Changes:
2440e189 Rebuild patches
4ecffced Update to Minecraft 1.13.1
2018-08-26 20:51:39 -04:00

59 lines
2.5 KiB
Diff

From 63f3b781dc0ddb6de219759f112f4d18cae510a5 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/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java
index cc7cad8be4..b8b514c874 100644
--- a/src/main/java/net/minecraft/server/RegionFile.java
+++ b/src/main/java/net/minecraft/server/RegionFile.java
@@ -238,8 +238,7 @@ public class RegionFile {
this.b(i, j, (int) (SystemUtils.d() / 1000L));
} catch (IOException ioexception) {
- ioexception.printStackTrace();
- ServerInternalException.reportInternalException(ioexception); // Paper
+ org.spigotmc.SneakyThrow.sneaky(ioexception); // Paper - we want the upper try/catch to retry this
}
}
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
index e5115863ec..2217adf99c 100644
--- a/src/main/java/net/minecraft/server/RegionFileCache.java
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
@@ -95,11 +95,29 @@ public class RegionFileCache {
@Nullable
public static synchronized void write(File file, int i, int j, NBTTagCompound nbttagcompound) throws IOException {
+ int attempts = 0; Exception laste = null; while (attempts++ < 5) { try { // Paper
RegionFile regionfile = a(file, i, j);
DataOutputStream dataoutputstream = regionfile.c(i & 31, j & 31);
NBTCompressedStreamTools.a(nbttagcompound, (java.io.DataOutput) dataoutputstream);
dataoutputstream.close();
+ // Paper start
+ laste = null; break; // Paper
+ } catch (Exception exception) {
+ //ChunkRegionLoader.a.error("Failed to save chunk", exception); // Paper
+ laste = exception; // Paper
+ }
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ if (laste != null) {
+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(laste);
+ MinecraftServer.LOGGER.error("Failed to save chunk", laste);
+ }
+ // Paper end
}
public static synchronized boolean chunkExists(File file, int i, int j) {
--
2.18.0