aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0403-Fix-Chunk-Post-Processing-deadlock-risk.patch
diff options
context:
space:
mode:
authorJason Penilla <[email protected]>2022-03-02 11:24:32 -0700
committerJason Penilla <[email protected]>2022-03-02 11:24:32 -0700
commit90788a556c6fb4a39919da2c440080b5daffe950 (patch)
treea672bded0e8251cfd545e4aaeba22b33cec99701 /patches/server/0403-Fix-Chunk-Post-Processing-deadlock-risk.patch
parent12d89fe5aec699dedbf529d1dc57b0deddb22409 (diff)
downloadPaper-90788a556c6fb4a39919da2c440080b5daffe950.tar.gz
Paper-90788a556c6fb4a39919da2c440080b5daffe950.zip
clean up prepareTickingChunk diff
Diffstat (limited to 'patches/server/0403-Fix-Chunk-Post-Processing-deadlock-risk.patch')
-rw-r--r--patches/server/0403-Fix-Chunk-Post-Processing-deadlock-risk.patch55
1 files changed, 10 insertions, 45 deletions
diff --git a/patches/server/0403-Fix-Chunk-Post-Processing-deadlock-risk.patch b/patches/server/0403-Fix-Chunk-Post-Processing-deadlock-risk.patch
index 23939da803..f3f4e5d8b2 100644
--- a/patches/server/0403-Fix-Chunk-Post-Processing-deadlock-risk.patch
+++ b/patches/server/0403-Fix-Chunk-Post-Processing-deadlock-risk.patch
@@ -8,7 +8,7 @@ See: https://gist.github.com/aikar/dd22bbd2a3d78a2fd3d92e95e9f28dc6
as part of post processing a chunk, we can call ChunkConverter.
ChunkConverter then kicks off major physics updates, and when blocks
-that have connections across chunk boundries occur, a recursive risk
+that have connections across chunk boundaries occur, a recursive risk
can occur where A updates a block that triggers a physics request.
That physics request may trigger a chunk request, that then enqueues
@@ -21,42 +21,11 @@ will be unable to proceed.
We delay post processing of Chunk.A() 1 "pass" by re stuffing it back into
the executor so that the mailbox ChunkQueue is now considered empty.
-This successfully fixed a reoccurring and highly reproduceable crash
+This successfully fixed a reoccurring and highly reproducible crash
for heightmaps.
-TODO FOR LEAF: 1.18.2 changed this
-
-OLD
-
- CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>> completablefuture1 = completablefuture.thenApplyAsync((either) -> {
- return either.flatMap((list) -> {
- LevelChunk chunk = (LevelChunk) list.get(list.size() / 2);
-
- chunk.postProcessGeneration();
- this.level.startTickingChunk(chunk);
- return Either.left(chunk);
- });
- }, (runnable) -> {
- this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, () -> ChunkMap.this.chunkLoadConversionCallbackExecutor.execute(runnable))); // Paper - delay running Chunk post processing until outside of the sorter to prevent a deadlock scenario when post processing causes another chunk request.
- });
-
-NEW
-
- CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>> completablefuture1 = completablefuture.thenApplyAsync((either) -> {
- return either.mapLeft((list) -> {
- return (LevelChunk) list.get(list.size() / 2);
- });
- }, (runnable) -> {
- this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, () -> ChunkMap.this.chunkLoadConversionCallbackExecutor.execute(runnable))); // Paper - delay running Chunk post processing until outside of the sorter to prevent a deadlock scenario when post processing causes another chunk request.
- }).thenApplyAsync((either) -> {
- return either.ifLeft((chunk) -> {
- chunk.postProcessGeneration();
- this.level.startTickingChunk(chunk);
- });
- }, this.mainThreadExecutor);
-
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
-index 7e3f7b69fc7a608dd82b471d832cc401a77f0738..d251e07eec07f8f822af1f8713e46aebe54b4890 100644
+index 7e3f7b69fc7a608dd82b471d832cc401a77f0738..95feb9e316d4d1115c7dad5873979708f8d647d9 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -178,6 +178,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -67,30 +36,26 @@ index 7e3f7b69fc7a608dd82b471d832cc401a77f0738..d251e07eec07f8f822af1f8713e46aeb
// Paper start - distance maps
private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets<ServerPlayer> pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>();
-@@ -1008,17 +1009,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
- return ChunkStatus.FULL;
+@@ -1009,16 +1010,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
});
CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>> completablefuture1 = completablefuture.thenApplyAsync((either) -> {
-- return either.mapLeft((list) -> {
+ return either.mapLeft((list) -> {
- return (LevelChunk) list.get(list.size() / 2);
- });
- }, (runnable) -> {
- this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, runnable));
- }).thenApplyAsync((either) -> {
- return either.ifLeft((chunk) -> {
-+ // Paper start
-+ return either.flatMap((list) -> {
-+ LevelChunk chunk = (LevelChunk) list.get(list.size() / 2);
++ // Paper start - revert 1.18.2 diff
++ final LevelChunk chunk = (LevelChunk) list.get(list.size() / 2);
chunk.postProcessGeneration();
this.level.startTickingChunk(chunk);
-+ return Either.left(chunk);
-+
++ return chunk;
});
- }, this.mainThreadExecutor);
+ }, (runnable) -> {
-+ this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, () -> ChunkMap.this.chunkLoadConversionCallbackExecutor.execute(runnable))); // Paper - delay running Chunk post processing until outside of the sorter to prevent a deadlock scenario when post processing causes another chunk request.
-+ });
-+ // Paper end
++ this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, () -> ChunkMap.this.chunkLoadConversionCallbackExecutor.execute(runnable))); // Paper - delay running Chunk post processing until outside of the sorter to prevent a deadlock scenario when post processing causes another chunk request.
++ }); // Paper end - revert 1.18.2 diff
completablefuture1.thenAcceptAsync((either) -> {
either.ifLeft((chunk) -> {