chore: Add initialization tracking for FDv2 Data Source.#205
chore: Add initialization tracking for FDv2 Data Source.#205kinyoklion merged 91 commits intomainfrom
Conversation
…ctional-data-source-updates
…rlamb/sdk-1584/fdv2-polling-data-source
…rlamb/sdk-1584/fdv2-polling-data-source
…rlamb/sdk-1584/fdv2-polling-data-source
…-1589/data-system-configurtion
…-1589/data-system-configurtion
…-1589/data-system-configurtion
| /// <summary> | ||
| /// We have received signals that indicate all fallbacks are exhausted. | ||
| /// </summary> | ||
| FallbackExhausted, |
There was a problem hiding this comment.
Is this reason this has to be tracked separately from Synchronizers is because the Fallback composite has its own FactoryList that exhausts separately from synchronizers?
There was a problem hiding this comment.
Yeah, without it we would end up basically in an orphaned state, or exit too early. Because if it is just a synchronizers, then the synchronizers would be exhausted twice.
The other thing is that each state is contingent on available states. Like if we don't fallback, we cannot wait for fallback to be exhausted. Or if we don't have synchronizers, etc.
pkgs/sdk/server/src/Internal/FDv2DataSources/FDv2DataSource.InitializationTracker.cs
Outdated
Show resolved
Hide resolved
pkgs/sdk/server/src/Internal/FDv2DataSources/FDv2DataSource.InitializationTracker.cs
Outdated
Show resolved
Hide resolved
pkgs/sdk/server/test/Internal/FDv2DataSources/FDv2DataSourceTest.cs
Outdated
Show resolved
Hide resolved
pkgs/sdk/server/src/Internal/FDv2DataSources/FDv2DataSource.InitializationTracker.cs
Show resolved
Hide resolved
c26dec6 to
3777ca2
Compare
pkgs/sdk/server/src/Internal/FDv2DataSources/FDv2DataSource.InitializationTracker.cs
Show resolved
Hide resolved
c65a280 to
bba9848
Compare
| { | ||
| _state = State.Failed; | ||
| } | ||
| } |
There was a problem hiding this comment.
Bug: Race condition in FDv1 fallback initialization tracking
When synchronizers fail with the FDv1Fallback flag, the CompositeObserver calls FDv1FallbackActionApplier first (which starts fdv1Synchronizers asynchronously), then calls synchronizationObserver second (which immediately sends SynchronizersExhausted). Since FallingBack is only sent when fdv1Synchronizers report Initializing state (asynchronously), SynchronizersExhausted is processed first. In InitializersExhausted state, receiving SynchronizersExhausted calls HandleRemainingSources() which sets state to Failed if both _initializersRemain and _synchronizersRemain are false. The comment at line 122 says "We only consider fallback if we have transitioned to fallback" but the implementation doesn't check the current state, causing premature failure before fdv1Synchronizers can provide data.
Note
Introduces initialization tracking for FDv2 with observer-driven composites, wraps the data source to complete on initialization, and updates polling/unrecoverable error behavior and tests.
InitializationTracker,InitializationObserver, andCompositeObserverto aggregate signals from initializers/synchronizers and determine init completion.CompletingDataSourcefromFDv2DataSource.CreateFDv2DataSourcethat completesStart()based on aggregated initialization rather than inner source start.FDv2DataSourceintoInternal/FDv2DataSourcesnamespace; replace direct applier wiring with observer composition; addDataSourceCategoryclassification.CompositeSourceusage; propagate status throughObservableDataSourceUpdates; continue to shut down withOffand exhaustion error when sources are depleted.falseand shut down; continue to markValidon 304 responses.FDv2DataSystemto newInternal.FDv2DataSourcestypes.Start()resultfalseon unrecoverable errors andtruewhen no sources; adjust expectations for initialization/fallback flows.streaming/fdv2/disconnects on goodbye.Written by Cursor Bugbot for commit bba9848. This will update automatically on new commits. Configure here.