Raft query peer event bus unification#1427
Open
zonotope wants to merge 7 commits into
Open
Conversation
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.
In raft mode, the
StateMachineAdapteremitsNameServiceEvents onRaftIntegration::event_bus, but the/v1/fluree/eventsSSE endpoint (and every other consumer that callsFluree::event_bus()) subscribes on a different bus — the oneFlureeallocates internally during build. Nothing bridged the two, so runtime raft commits never reached SSE subscribers. The bug hid because the endpoint's connection-time snapshot reads straight from the nameservice: data present at connect appeared, subsequent inserts did not. Query peers subscribed to a raft cluster therefore never heard about new commits.Separately,
Fluree's local cache event listener (which reconciles theLedgerManageron commit/index events and evicts on retract) was only spawned when background indexing was enabled. Query peers run without indexing, so they had no listener at all and depended onPeerSyncTaskmanually re-notifying theLedgerManagerafter every nameservice update.Fix
FlureeBuildergainswith_event_bus(Arc<LedgerEventBus>): a caller-supplied bus is used instead of allocating a fresh one, uniformly across everybuild_*path (via a singleresolve_event_bushelper). The raft server assembly threadsRaftIntegration::event_busthroughbuild_fluree_with_nameservice/build_default_flureeinto the builder, so the state-machine adapter (publisher) and the SSE events endpoint, registry maintenance task, and cache listener (subscribers) all share one broadcast channel.The local cache event listener is now spawned whenever a
LedgerManagerexists, independent of indexing mode. This gives query peers cache reconciliation driven by the events theirNotifyingNameServicealready emits on successful CAS operations.Consequent removals
spawn_local_cache_event_listenercall on the raft bus is gone — the builder-spawned listener now covers it (this also removes a duplicate reconcile task that previously ran on raft nodes with indexing enabled).PeerSyncTask::refresh_cached_ledgerand its manualLedgerManagernotification are gone:fast_forward_commitdispatches throughNotifyingNameService::compare_and_set_ref, which emitsLedgerCommitPublished/LedgerIndexPublishedonUpdated, and the always-running listener reconciles from the just-updated local nameservice.NotifyingNameService::retractemitsLedgerRetracted, and the listener'sledger_manager.disconnectis exactly whatFluree::disconnect_ledgerdid.Behavior change for embedders
The synchronous builders (
build_memory(),build_with(), etc.) previously spawned no tasks when indexing was disabled and worked outside an async context. They now spawn the cache listener whenever ledger caching is enabled (the default), so allbuild_*methods must be called within a tokio runtime. TheFlureeBuilderdocs state this, and the affected unit tests were converted to#[tokio::test].