Do not create rolling-database list entries on syncOnly processes#38
Open
peachbits wants to merge 1 commit into
Open
Do not create rolling-database list entries on syncOnly processes#38peachbits wants to merge 1 commit into
peachbits wants to merge 1 commit into
Conversation
A syncOnly process appended period/spare entries to the -list database via addDb, but physical database creation is gated behind !syncOnly. This let a sync-only process register a database it would never create, so queries routing to that period would 500 until the primary process independently ran readDbList. Gate the list-mutation blocks behind !syncOnly so only the authoritative process both writes the list doc and creates the database, in the same readDbList pass.
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.
CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
none
Description
Fixes a split across the
syncOnlygate in rolling-database setup that let a sync-only process register a period database it would never physically create.In
readDbList, appending an entry to the-listdatabase (addDb) was ungated, but physical database creation runs insidesetupDatabaseonly when!syncOnly. Since a cluster wiressyncOnly: !cluster.isPrimary, a worker crossing a period boundary would write the spare/period list doc without creating the database. The database was only created later when the primary independently ranreadDbList(startup, the 24h periodic task, or a-listonChange). If the primary's change notification was missed and its periodic tick had not elapsed, the database stayed missing, and once its active window opened, queries routed there returned 500 until a restart forced the primary's startupreadDbList.Changes:
syncOnlyfrom the setup options insidesetup(it was never destructured, so the list-mutation path could not observe it).!syncOnly, with alist.length > 0guard on the spare block so an empty list cannot throw onlist[0].startDate.Now only the authoritative (non-syncOnly) process both writes the list doc and creates the database, in the same
readDbListpass. Sync-only processes still pick up new databases through the existing-listonChange watcher.Added a CHANGELOG entry under Unreleased. Verified with
yarn typesandyarn test.Note
Medium Risk
Touches rolling-database lifecycle at period boundaries and query routing; change is narrow but correctness-critical for multi-cluster primary/worker setups.
Overview
Fixes a split where
syncOnlyworkers could append period entries to the rolling*-listdatabase whilesetupDatabaseskipped creating the matching physical DB on those processes. That could leave queries routing to missing databases (500s) until the primary caught up.readDbListinrolling-database.tsnow readssyncOnlyfrom setup options and runs empty-list backfill and future spare creation only when!syncOnly. The spare-period path also requireslist.length > 0so an empty list cannot dereferencelist[0]. Sync-only processes still load the list and react via the existing-listwatcher; only the authoritative process both writes list docs and creates databases in the same pass.CHANGELOG updated under Unreleased.
Reviewed by Cursor Bugbot for commit 0aa2413. Bugbot is set up for automated code reviews on this repo. Configure here.