Repository navigation
fix: Publish the data source status before releasing ready waiters - #431
Merged
Merged
Conversation
jsonbailey
marked this pull request as ready for review
September 2, 2026 21:50
kinyoklion
reviewed
Sep 2, 2026
|
|
||
| expect(listener.statuses.count).to eq(1) | ||
| expect(listener.statuses[0].state).to eq(Interfaces::DataSource::Status::VALID) | ||
| # The poll thread sets the ready event before it publishes the VALID |
Member
There was a problem hiding this comment.
Is there a reason it is in this order? Go was also doing this and I just swapped them because you would expect the status to be set before the ready event.
jsonbailey
force-pushed
the
jb/polling-spec-flake
branch
from
September 9, 2026 21:58
ea48542 to
b3fcc65
Compare
jsonbailey
marked this pull request as draft
September 9, 2026 22:00
FDv1 polling and the FDv2 synchronizer loop both set the ready event before publishing the VALID data source status. A caller that returned from start could therefore read a status that did not yet reflect the successful poll. Both now publish the status first and set the ready event afterwards, matching the OFF path fixed in #429. The polling spec no longer needs to wait for the VALID status, because the broadcaster notifies listeners inline on the poll thread and the ready event is now set after that. The recoverable-error spec keeps its wait: that path publishes INTERRUPTED and never sets the ready event, so there is nothing to synchronize against.
The FDv2 initializer phase raised the ready event without reporting any status, so a client configured with initializers returned from start with a data source status that still read INITIALIZING. With no synchronizers configured nothing ever published VALID, so the status stayed wrong for the lifetime of the data system. The initializer now publishes VALID before releasing ready waiters, the same order as the synchronizer loop and matching the Java server SDK. Publishing here does not duplicate the synchronizer's later VALID, which UpdateSink#update_status drops as an unchanged state.
jsonbailey
force-pushed
the
jb/polling-spec-flake
branch
from
September 30, 2026 21:54
b3fcc65 to
549912d
Compare
3 tasks done
The status publish and the ready event sit next to each other, so the order needs no explanation. In the FDv1 polling path the comment was also above the ready event rather than above the publish four lines up, so it described the wrong line.
jsonbailey
marked this pull request as ready for review
October 2, 2026 21:03
kinyoklion
approved these changes
Oct 2, 2026
jsonbailey
pushed a commit
that referenced
this pull request
Oct 6, 2026
🤖 I have created a release *beep* *boop* --- ## [8.18.1](8.18.0...8.18.1) (2026-10-06) ### Bug Fixes * Pass connect_timeout to the streaming SSE client ([#458](#458)) ([f4a07af](f4a07af)) * Prevent close from hanging after a persistent store read fails ([91b7c9c](91b7c9c)) * Prevent flags from falling back to defaults when a deleted item has no key ([afb9f3d](afb9f3d)) * Prevent flags from falling back to defaults when Consul holds one item ([8891226](8891226)) * Prevent the store availability poller from outliving the client ([91b7c9c](91b7c9c)) * Publish the data source status before releasing ready waiters ([#431](#431)) ([0e224b9](0e224b9)) * Reuse an in-flight big segment status poll instead of querying twice ([#460](#460)) ([96cca28](96cca28)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Overview** > This **Release Please** PR cuts **8.18.1** by bumping `LaunchDarkly::VERSION`, `.release-please-manifest.json`, and the provenance example in `PROVENANCE.md`. > > It adds a **8.18.1** section to `CHANGELOG.md` documenting bug fixes already landed on main: streaming **connect_timeout** wiring, persistent-store **close** and availability-poller lifecycle, flag-evaluation fallbacks with deleted/Consul store edge cases, **data source status** ordering before ready waiters, and deduplicating **big segment** status polls. No SDK implementation files change in this diff—only release bookkeeping. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 46d0611. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
Requirements
Related issues
Follows #429, which fixed the same ordering problem on the unrecoverable-error path. Reworked from a spec-only change after @kinyoklion pointed out that the ordering itself was the bug — matching the change he has already merged in the Go SDK (go-server-sdk#442).
Describe the solution you've provided
1. Publish the status before releasing ready waiters
Three places raised the ready event before reporting a status, so a caller that returned from
startcould read adata_source_status_provider.statusthat did not yet reflect reality:PollingProcessor#poll(FDv1) set the ready event and only then publishedVALID.VALID, so the status stayedINITIALIZINGfor the lifetime of the data system.All three now publish the status first and set the ready event afterwards. This is the same argument #429 made for the
OFFpath, applied to the success paths, and it matches the Java server SDK, where every readiness site reports status first (FDv2DataSource.java).2. The success spec no longer needs to wait
This PR started as a spec-only fix that waited for the listener to be notified. With the ordering corrected that wait is unnecessary, so
status is set to valid when data is receivedis back to its original form, unchanged frommain.Worth correcting one claim from the original description: delivery here is not asynchronous. The polling spec uses
SynchronousExecutor, whosepostjust yields, soBroadcaster#broadcastcallslistener.updateinline. The distinction is which thread — inline on the poll thread, not the spec thread. That is why the old ordering was racy and why the new ordering makes the assertion deterministic: by the time@ready.setruns, the listener has already returned on that same thread.3. The recoverable-error spec still needs its wait
verify_recoverable_http_error(408, 429, 503) keepswait_for_count(2). That path publishesINTERRUPTEDand never sets the ready event, so there is no event to reorder and the pre-existingready.wait(1)was only passing time.ListenerSpy's mutex and condition variable stay for the same reason — without an event there is no happens-before for the cross-thread read, and a bare array appended from the poll thread and read from the spec thread is a real data race on JRuby.wait_for_statusis removed;wait_for_countis the only helper still used.Describe alternatives you've considered
Keeping the spec-only fix. It would have made CI green while leaving an observable ordering problem in the SDK, which is the same trade #429 declined.
Hoisting
update_statusabove the guards instead of introducing locals. InPollingProcessor#pollthat would publishVALIDbeforeupdate_sink_or_data_store.init, so a store failure would reportVALIDthenINTERRUPTED, and it would escapeINITIALIZINGbefore the write and so defeat theINTERRUPTED→INITIALIZINGcoercion inUpdateSink#update_status. In the FDv2 synchronizer loop it would moverecord_environment_idafter the status publish. Go solves the latter by hoistingSetEnvironmentIDout of the state switch entirely; that is a small deliberate behavior change and is left for a follow-up.Additional context
Two further gaps from the same spec area are not addressed here, both from SDK-2980 (closed) under epic SDK-2993:
anyDataReceivedflag; Go added it in go-server-sdk#441.Interrupted, apply no data, and not raise readiness.data_system/streaming.rbreportsVALIDfor atransfer-noneserver intent unconditionally.Both change when readiness fires rather than what the status says at that moment, so they are behavior changes with spec weight and want their own PR. There is no contract-test coverage for any of this today: the harness has no way to read an SDK's data source status, and cannot construct a payload with an absent selector.
Also not touched, deliberately:
@disabledpath raises readiness with no status. Java has no direct analogue.falseand reports unexpected exhaustion; Ruby's ready event carries no success flag, so matching that needs an API discussion rather than a line change.Validation
bc6a166.spec/launchdarkly-server-sdk_spec.rb:5, the Bundler.require smoke test, which also fails at this branch's merge base in a worktree checkout and passes in a normal clone. Unrelated to these changes. The gap against CI is the redis, dynamodb, and consul store specs, which need backing services.polling_spec.rb+fdv2_datasystem_spec.rb: 35 examples, 0 failures; looped 15 times with no failures.expected: :valid, got: :initializing.Note
Overview
Ensures data source status is published before the ready event is signaled, so callers returning from
startcan readVALID(or the correct state) instead of staleINITIALIZING.In FDv1 polling,
PollingProcessor#pollnow callsupdate_status(VALID)before@ready.seton first successful init. In FDv2, the initializer success path now reportsVALIDwhen a defined selector is present (previously it could stayINITIALIZINGwith initializer-only configs), and the synchronizer loop reports status before setting@ready_event.Specs add ordering assertions for polling and FDv2, and
ListenerSpygains mutex/condition-variablewait_for_countfor cross-thread status assertions on recoverable error paths where ready is never set.Reviewed by Cursor Bugbot for commit e9a05b7. Bugbot is set up for automated code reviews on this repo. Configure here.