Fix recursive deadlock in CraftWorld.isChunkGenerated#34
Fix recursive deadlock in CraftWorld.isChunkGenerated#34UnlimitedBytes wants to merge 1 commit intoMultiPaper:ver/1.21.11from
Conversation
|
What Chunky commands did you run to produce this? |
|
The commands used: This test was specifically designed to trigger this exception, it will not occur on normal use of the plugin, however it still will happen if multiple plugins try to check chunk generation at the same time. |
|
I tried running those commands three times, no luck. Can you send the logs you got? |
|
This isn't a recursive issue like you think, this is just Chunky hitting the server with so many async requests that the tick thread never gets a break and is constantly handling new isChunkGenerated requests. It's not good to return |
Summary
Fixes a recursive deadlock in
CraftWorld.isChunkGeneratedthat occurs when plugins (like Chunky) call the method from multiple threads simultaneously during chunk pre-generation.Problem
The original implementation used
managedBlockto process tasks while waiting for chunk data. WhenmanagedBlockprocessed tasks, it could execute otherisChunkGeneratedcalls, which would also callmanagedBlock, creating:Solution
ThreadLocal<Boolean>flag to track when we're already insideisChunkGeneratedfuture.join()withoutmanagedBlockto avoid recursive task processingfalse(conservative answer) without blockingmanagedBlocknormally to process chunk loadBehavior Change
Recursive calls to
isChunkGeneratednow returnfalsewhen the chunk isn't immediately available in memory, rather than blocking. This is a conservative answer that:Testing
isChunkGeneratedusages in codebase - no breaking changes identified