CBG-5472 part 3 of 3: read databases lock-free when collecting calculated stats - #8684
Open
bbrks wants to merge 1 commit into
Open
CBG-5472 part 3 of 3: read databases lock-free when collecting calculated stats#8684bbrks wants to merge 1 commit into
bbrks wants to merge 1 commit into
Conversation
Contributor
updateCalculatedStats took _databasesLock for read, which a config update can hold for write across a long wait on index readiness. The stats logger then stalls for the duration, so the collection it is in the middle of is late or missed entirely. Keep an atomic snapshot of the _databases values alongside the map, refreshed by _addDatabase/_deleteDatabase/_clearDatabases, and have updateCalculatedStats read that instead. It now never blocks on the lock. Dropping the lock means the reader can see a database that is being torn down, since _unloadDatabase closes the context under the write lock it no longer waits for. The DBStopping state Close sets is what keeps it out: the DBOnline guard skips it, and _unloadDatabase drops it from the snapshot before calling Close so the reader stops seeing it first. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
bbrks
force-pushed
the
CBG-5472-stats-snapshot
branch
from
August 27, 2026 08:52
2f1bdbe to
96bd1c8
Compare
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.
CBG-5472
Part 3 of 3 split from #8431 - which had in-PR requested changes that ended up spiralling away from the original ticket.
Integration Tests