Skip to content

Edge case in generation system when external systems (e.g. in plugins) lock chunks #6680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dktapps opened this issue Apr 26, 2025 · 0 comments
Labels
Category: Core Related to internal functionality Status: Debugged Cause of the bug has been found, but not fixed

Comments

@dktapps
Copy link
Member

dktapps commented Apr 26, 2025

Problem description

World->lockChunk() is used for advisory locking for async worldgen. Async generation won't take place if a chunk is locked.

However, we don't account for the possibility that the source of the chunk locking wasn't the generation subsystem. The assumption here that a generation request has locked the chunk is problematic:

//chunk is already in use by another generation request; queue the request for later

A deferred generation request is pushed onto the queue, but because the queue drainage is only triggered by other generation tasks completing, if there are no additional tasks, the request will never get processed.

This bug requires a conjunction of two things:

  1. no subsequent generation requests to be submitted
  2. the chunk to be locked by something outside the generation system (e.g. in a plugin)

Proposed solution

Some possible options come to mind:

  1. a ticking function called by World to make sure the queue doesn't stagnate even if no new generation requests arrive
  2. support callbacks (or Promises?) to get notified when a chunk is unlocked, which could be used to trigger queue processing
  3. global callbacks for World->unlockChunk() to trigger stuff like population queue flushes - although this might get complicated during generation callbacks

Alternative solutions or workarounds

No response

@dktapps dktapps added Category: Core Related to internal functionality Status: Debugged Cause of the bug has been found, but not fixed labels Apr 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Core Related to internal functionality Status: Debugged Cause of the bug has been found, but not fixed
Projects
None yet
Development

No branches or pull requests

1 participant