feat: add server FDv2 data system orchestrator#529
Merged
Conversation
Member
|
Potential test suggestions in Just validating the behavior of destruction mid-synchronization/initialization. |
Member
|
And another set of test suggestions in |
Adds two regression tests that exercise the destruction protocol contract documented on FDv2DataSystem: when the destructor runs while an initializer or synchronizer Future is unresolved, the orchestrator must close the active source, transition status to kOff, and tear down the captured-this continuation chain without firing it against the destroyed object. Existing Destructor_TransitionsStatusToOff only covers the offline-mode case (no factories, no orchestration ever started); the in-flight teardown paths were not exercised. Adds StalledInitializer / StalledSynchronizer mocks that return an unresolved Future to drive the orchestrator into the in-flight state, then destroy the data system before the future resolves.
Adds two regression tests for the Goodbye handling added in d154cbe: - GoodbyeEventTriggersAsyncRestart: verifies that on receiving a goodbye event, the synchronizer drives sse::Client::async_restart with the documented reason string. Without this, the server's "we're about to disconnect" signal would lead to a stalled connection rather than a controlled reconnect. Adds a MockSseClient that records calls and a SetSseClient test peer to inject it. - GoodbyeMidPayloadDiscardsAccumulatedAndAcceptsFreshChangeset: feeds a partial payload, then a goodbye, then a fresh full changeset, and asserts that the accumulated puts were discarded and only the fresh put is in the resulting ChangeSet. Locks in the spec-aligned property that Goodbye does not corrupt subsequent payloads.
Adds SynchronizerGoodbye_PreservesSelectorOnNextCall: drives the orchestrator through initializer-basis@v1 -> ChangeSet@v2 -> Goodbye -> Shutdown, and asserts the captured Next() selectors are v1, v2, v2 in order. The existing SynchronizerGoodbye_StaysOnSameSynchronizer test only checks that Goodbye does not rotate the synchronizer factory; it does not verify what selector the post-Goodbye Next() call receives. Without this preservation, the SDK would reconnect with stale or empty payload state on every Goodbye, forcing the server into expensive xfer-full responses instead of efficient xfer-changes. Verified load-bearing: temporarily clearing selector_ on Goodbye in fdv2_data_system.cpp makes only this test fail (the existing Goodbye test still passes).
kinyoklion
approved these changes
May 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.
Add FDv2DataSystem orchestrator
Orchestrates FDv2 initializers and synchronizers; applies changesets and reports data-source status.
What's implemented
FDv2DataSystem—IDataSystemimpl. Runs initializers, then a synchronizer; applies changesets; tracks the selector; emits status (kInitializing→kValidon first apply /kInterruptedon errors →kOffon destruction). Offline (no factories) goes straight tokValid.IFDv2InitializerFactory,IFDv2SynchronizerFactory— build a fresh source per call.ITransactionalDestination— extendsIDestinationwithApply(ChangeSet); implemented byMemoryStoreandChangeNotifier.ChangeNotifier::Apply— diffs against the current store, updates the dependency tracker, applies to the sink, emits change events. Full diffs per-kind and version-aware; Partial notifies unconditionally per item.Design decisions
shared_ptr<State>for orchestrator-level async safety. Other FDv2 components keep async state in ashared_ptr<State>so callbacks can outlive the public object. This one capturesthisdirectly — safe because~ClientImpldoesioc_.stop()andrun_thread_.join()before destroying the data system. This was done becauseClientImplis shared with FDv1.ITransactionalDestinationrather than addingApplytoIDestination. Leaves the FDv1 persistent-store path untouched.DataSourceStatusManageris non-owning.ClientImpl(shared with FDv1) is its sole owner; the data system only borrows it. Declaration order inClientImplguarantees the manager outlives the data system.Test plan
11 cases in
libs/server-sdk/tests/fdv2_data_system_test.cppcover lifecycle, initializer phase (basis received, basis-skips-remaining, Interrupted advances, ChangeSet without selector continues), and synchronizer phase (apply, Interrupted loops, Goodbye/TerminalError advances, selector forwarding). Mocks resolve futures synchronously; tests run the io_context to drain orchestration before assertions.Note
Medium Risk
Introduces new FDv2 orchestration and a transactional changeset apply path that affects how flags/segments are updated and how change notifications fire; bugs here could lead to stale/incorrect flag state or missed updates under concurrency.
Overview
Implements a new
FDv2DataSystemthat orchestrates FDv2 initializers and synchronizers on an executor, applies incoming changesets into an in-memory store, tracks the latest selector for incremental updates, and drivesDataSourceStatusManagertransitions.Adds
ITransactionalDestination(extendingIDestination) plusChangeNotifier::Applysupport so full/partial/none changesets can be applied atomically while updating dependency tracking and emitting change events;MemoryStoreandChangeNotifierare updated to implement this interface.Improves
FDv2StreamingSynchronizerhandling ofgoodbyeevents by resetting protocol state and restarting the underlying SSE connection; adds/extends unit tests for the new orchestrator, changeset apply semantics, and goodbye restart/reset behavior.Reviewed by Cursor Bugbot for commit 7a147d2. Bugbot is set up for automated code reviews on this repo. Configure here.