fix: Report data source Valid status before signaling readiness - #442
Merged
Conversation
kinyoklion
marked this pull request as ready for review
September 2, 2026 17:23
jsonbailey
approved these changes
Sep 2, 2026
jsonbailey
approved these changes
Sep 2, 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.
Summary
Fixes a flaky test failure (
TestDefaultDataSourceIsStreaming, seen on CI as statusINITIALIZINGinstead ofVALIDright after a successful client start) caused by an ordering race between the readiness signal and the data source status update.In the FDv1 streaming data source, a successful initial
putclosed thecloseWhenReadychannel before updating the data source status to Valid. A caller blocked inMakeCustomClientcan wake on the channel close and read the status while it still says Initializing. The FDv2 synchronizer path had the same ordering (channel close beforeUpdateStatus). The FDv1 polling data source already does this in the correct order (status first, then readiness), so this change brings the other two paths in line with it.For the streaming source, the
Validstatus update stays in its single existing location after the event handling; the put branch now records that initialization occurred, and the readiness notification runs after that shared status update.setInitializedAndNotifyClientis idempotent (atomic initialized flag plussync.Oncefor the channel close), so the deferred notification is safe.The race window is a few instructions wide, so it only fires on loaded runners. Verified by widening the window with a temporary sleep: the test fails deterministically with the exact CI failure signature under the old ordering, and passes 50/50 with the new ordering even with a sleep inserted between the status update and the readiness notification.
Also adds an immediate post-start status assertion to
TestFDV2StreamingSynchronizerso the FDv2 ordering is regression-tested the same wayTestDefaultDataSourceIsStreamingcovers FDv1.Note
Overview
Fixes a race where readiness (
closeWhenReady) could fire before the data source reported Valid, so callers waking on client start could still seeINITIALIZING(flakyTestDefaultDataSourceIsStreamingon CI).In FDv1 streaming, a successful initial
putno longer closes the readiness channel inside the init branch; it deferssetInitializedAndNotifyClientuntil after the sharedUpdateStatus(Valid)path runs for the event. FDv2fdv2_datasystemnow callsUpdateStatusbeforereadyOnceclosescloseWhenReady, matching the polling data source’s status-first ordering.FDv2 e2e (
TestFDV2StreamingSynchronizer) asserts Valid status immediately afterMakeCustomClientreturns instead of blocking onWaitFor, so FDv2 ordering is regression-tested like the FDv1 streaming test.Reviewed by Cursor Bugbot for commit 633c389. Bugbot is set up for automated code reviews on this repo. Configure here.