Skip to content

Fix async mob spawning deadlock on structure_starts chunk loads#173

Open
XUANHLGG wants to merge 1 commit into
AxalotLDev:multiloader-1.21.11from
XUANHLGG:multiloader-1.21.11
Open

Fix async mob spawning deadlock on structure_starts chunk loads#173
XUANHLGG wants to merge 1 commit into
AxalotLDev:multiloader-1.21.11from
XUANHLGG:multiloader-1.21.11

Conversation

@XUANHLGG

@XUANHLGG XUANHLGG commented May 3, 2026

Copy link
Copy Markdown

I ran into a server hang where multiple Async-Tick-Pool-Threads were stuck on Sync load chunk to status minecraft:structure_starts in world minecraft:overworld, and the server was killed by watchdog after about one minute.

The original implementation had two problems:
tickChunksSpawn() could run natural mob spawning on the async pool
non-main-thread async$getChunk() could still reach create=true or high-risk chunk states such as structure_starts, which could make async workers wait for main-thread chunk loading
That creates a wait cycle: async worker threads wait for chunk loading, while the server thread can end up waiting for async worker completion.

This PR changes that behavior by:
adding enableAsyncMobSpawning as a separate config option
defaulting async natural mob spawning to disabled when C2ME is detected via getDefaultAsyncMobSpawning()
blocking unsafe async chunk requests in async$getChunk()
making shortcutGetChunkNow() only read already-loaded FULL chunks instead of triggering generation from worker threads
forcing natural mob spawning to fall back to synchronous execution when async spawning becomes unsafe in tickChunksSpawn()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant