aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0069-Chunk-Save-Reattempt.patch
blob: b6cbc2cd95ee658b95ad5459a8f8b3be4825665e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
From 98431cfef4644e54f94e1379dce74e6648c497b9 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/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index 4c3faa20..12bd558a 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -194,11 +194,16 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
                 // CraftBukkit
 
                 if (nbttagcompound != null) {
+                    int attempts = 0; Exception laste = null; while (attempts++ < 5) { // Paper
                     try {
                         this.b(chunkcoordintpair, nbttagcompound);
+                        laste = null; break; // Paper
                     } catch (Exception exception) {
-                        ChunkRegionLoader.a.error("Failed to save chunk", exception);
+                        //ChunkRegionLoader.a.error("Failed to save chunk", exception); // Paper
+                        laste = exception; // Paper
                     }
+                    try {Thread.sleep(10);} catch (InterruptedException e) {e.printStackTrace();} } // Paper
+                    if (laste != null) { com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(laste); MinecraftServer.LOGGER.error("Failed to save chunk", laste); } // Paper
                 }
                 synchronized (lock) { if (this.b.get(chunkcoordintpair) == chunk.compoundSupplier) { this.b.remove(chunkcoordintpair); } }// Paper - This will not equal if a newer version is still pending
 
diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java
index d2f08802..c3424a35 100644
--- a/src/main/java/net/minecraft/server/RegionFile.java
+++ b/src/main/java/net/minecraft/server/RegionFile.java
@@ -248,8 +248,7 @@ public class RegionFile {
 
             this.b(i, j, (int) (MinecraftServer.aw() / 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
         }
 
     }
-- 
2.20.1