Fix async mob spawning deadlock on structure_starts chunk loads#173
Open
XUANHLGG wants to merge 1 commit into
Open
Fix async mob spawning deadlock on structure_starts chunk loads#173XUANHLGG wants to merge 1 commit into
XUANHLGG wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 poolnon-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 loadingThat 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
enableAsyncMobSpawningas a separate config optiondefaulting 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 threadsforcing natural mob spawning to fall back to synchronous execution when async spawning becomes unsafe in
tickChunksSpawn()