Repository navigation
fix: Prevent TestDataV2 from briefly restoring an older flag when a client starts - #491
Merged
keelerm84 merged 1 commit intoNov 6, 2026
Conversation
…lient starts A TestDataV2 data source registered for changes when it was created, not when it started to sync. A change made between those two points was in the initial data and also waited in the queue. The sync then sent the queued change after the initial data, so the store went back to an older version until the later changes arrived. The sync now registers and takes the initial data in one step, under the lock that an update holds while it saves a change and copies the list of instances. Each change then reaches a synchronizer once, and in order. An initializer only fetches, so it no longer registers. Before this change, FDv2 never stopped its initializers, and each one stayed registered and queued every later change.
jsonbailey
approved these changes
Nov 6, 2026
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.
A TestDataV2 data source registered for changes when it was created, not
when it started to sync. A change made between those two points was in
the initial data and also waited in the queue. The sync then sent the
queued change after the initial data, so the store went back to an older
version until the later changes arrived.
The sync now registers and takes the initial data in one step, under the
lock that an update holds while it saves a change and copies the list of
instances. Each change then reaches a synchronizer once, and in order.
An initializer only fetches, so it no longer registers. Before this
change, FDv2 never stopped its initializers, and each one stayed
registered and queued every later change.
Note
Overview
Fixes TestDataV2 sources registering too early and replaying pre-sync changes after the initial full snapshot, which could briefly restore an older flag version when a client started.
TestDataSourceV2no longer auto-registers on construct.syncsubscribes and builds the initial basis in one step viafetch_result { @test_data.subscribe(self) }, so the queue only gets updates after that snapshot.fetch(initializer path) uses the samefetch_resulthelper but onlymake_init_data+get_version, so it does not subscribe and will not keep receivingupsert_flagcalls.TestDataV2#add_instanceis replaced bysubscribe, which atomically adds the instance, snapshots current flags/segments, and returns the version used for the initial transfer. A privatefetch_resultcentralizes lock/error handling andFetchResultwrapping.Specs exercise explicit
subscribe, assert no stale update after the initial sync, and assert initializers do not receive subsequentupsert_flagtraffic.Reviewed by Cursor Bugbot for commit e5b88af. Bugbot is set up for automated code reviews on this repo. Configure here.