Repository navigation
Conversation
…erChanged A transaction that reached a node which had stopped leading, or whose wait a new leader's snapshot cut off, answered 503 typed err:system/InternalError. Both now answer 503 with err:db/LeaderChanged and Retry-After, through a typed SubmissionError::LeaderChanged that stays unsettled, so a keyed retry is not recorded as a failure.
…released once one lands While the leader is unreachable, the owning worker stages its queue entry again on every retry. Each attempt writes a new commit file, and an attempt whose publish outcome is unknown keeps its file in case it became the head, so a long outage left one orphan per retry. The worker now remembers those files for the entry. Only one commit can take a queue entry, so once a later attempt of the same worker lands, the others can never become the head and are released. Pushes and fast-forwards name commits the worker did not write, so they are not tracked.
…ough the leader A cluster's leader built an index after every commit: its indexer subscribed to every commit event, which no threshold gates, so a raised --reindex-min-bytes did nothing on a cluster, and it ran even with --indexing-enabled=false. The other members ran no indexer, and an index publish from a member that did not lead was dropped as a success. - A member built with the replicated nameservice now runs its background indexer, like a standalone server. The commit worker triggers it once a commit brings the branch's novelty to --reindex-min-bytes, or after a fast-forward. The trigger is armed before the publish and waits for this member to apply the commit, since applying it can stop the worker and the indexer reads the head from the replicated state. - A member that does not lead publishes an index head over POST /raft/apply_index_head, which the leader proposes. A leader of an earlier release answers 404, and the build is retried. - The leader's indexer no longer subscribes to commits. It keeps its catch-up sweeps for ledgers left behind, and the operator's GC retention, so a sweep's build collects as the owners' do. - A cluster member with --indexing-enabled=false refuses to start: no process outside the cluster can publish its indexes. A test this change loads harder waited for no voter to be demoted right after bootstrap. Its 500 ms threshold demoted one starved of CPU by the binary's other clusters, so it now waits for the full voter set.
…ns its log fluree-server validated its configuration only while building the server, after it had bootstrapped Raft: a cluster member started with --indexing-enabled=false opened its log and started as a follower before it refused. main now validates first.
…y claim An error that may not be the submission's outcome is not recorded in the idempotency cache, and the claim was meant to be released. Every caller then marked the claim done anyway, so it stayed InFlight for the cache TTL (an hour) and every keyed retry on that node answered AlreadyInFlight. The worst case was a key collision. A request that reused a key with another body, on a node whose cache did not hold the key (after a restart), was refused by the replicated map. Its claim stayed under the colliding body, and the original request's retries answered KeyCollision for the hour. A LeaderChanged answer, which tells the client to retry with the same key, pinned the key the same way. record_outcome now takes the claim and releases it before returning when the error is unsettled. A keyed retry runs again: under Raft the replicated map answers it with the queued entry or its receipt, and a local execution has nothing left running once it returns.
This branch has not been deployed
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.
Raft fixes found while testing three-node clusters, one commit each.
Each member indexes the branches it owns
A cluster indexed in one place, the leader's indexer, which subscribed to every commit event. That subscription has no byte gate, so:
--reindex-min-byteschanged nothing on a cluster;--indexing-enabled=falsedid not stop it.The other members ran no indexer at all: a
Flureebuilt with a supplied nameservice gotIndexingMode::Disabled. AndRaftNameService::publish_indexon a member that did not lead dropped the head and reported success, which #1768 describes.Indexing now follows branch ownership, as staging does:
--reindex-min-bytes, or after a fast-forward merge.t. It is spawned before the publish: applying the commit can empty the branch's queue, and the supervisor then stops the worker wherever it is.POST /raft/apply_index_head, which proposesAdvanceIndexHead, orRewriteIndexHeadfor an admin rebuild. No outcome reads as success unless the head was proposed: a lost answer, a step-down or no known leader isProposeUnresolved, and the indexer retries.--indexer-catchup-interval-secs) for ledgers left behind, and now takes the operator's GC retention, so its builds collect as the owners' do.--indexing-enabled=falseis refused on a cluster member, throughServerConfig::validateand throughFlureeServerBuilder::with_raft: no process outside the cluster can publish its indexes.fluree-serverused to validate only while building the server, after it had bootstrapped Raft; it now validates first, so a refused configuration never opens the log.Leadership-change 503s are typed
A transaction that reached a node which had stopped leading, or whose wait a new leader's snapshot cut off, answered 503 typed
err:system/InternalError. Both now answer 503err:db/LeaderChangedwithRetry-After, throughSubmissionError::LeaderChanged, which stays unsettled so a keyed retry is not recorded as a failure. A Raft fatal during enqueue keeps its 503: that node's Raft has stopped.Commit files from unanswered publishes are released
While the leader is unreachable, the owning worker stages its entry again on every retry (about every 250 ms). Each attempt writes a new commit file, and one whose publish outcome is unknown is kept in case it became the head, so an outage left one orphan per retry. The worker now remembers them for the entry. Only one commit can take a queue entry, so once a later attempt lands, the rest can never become the head and are released. Pushes and fast-forwards name commits the worker did not write and are not tracked. A worker stopped mid-outage still leaves its files.
An unsettled error releases its idempotency claim
CachingCommitterdoes not record an error that may not be the submission's outcome (is_settled() == false), and its comment says the claim is then released. Every caller marked the claim done regardless, so it stayedInFlightfor the cache TTL (an hour) and every keyed retry on that node answeredAlreadyInFlight. In the worst case, a request reusing a key with another body reached a node whose cache did not hold the key (after a restart). The replicated map refused it as a collision, but its claim stayed under the colliding body, so the original request's retries answeredKeyCollisionfor the hour. This also happens on v4.2.9. ALeaderChangedanswer, which tells the client to retry with the same key, pinned the key the same way.record_outcomenow takes the claim and releases it before returning when the error is unsettled. A keyed retry runs again: under Raft the replicated map answers it with the queued entry or its receipt, and the unsettled errors a local execution can return all come before its commit.Rolling upgrade
/raft/apply_index_headis a new route. Until the leader runs this release, it builds after every commit as before, and answers an upgraded follower's index publish with 404; the follower logsFailed to publish index, will retryand finds the leader's index on its next attempt. Upgrading the leader last, as documented, avoids the reverse window, in which a branch owned by an older follower would be indexed only by the leader's catch-up sweep. No replicated command changed.A reindex is forwarded to the leader and holds that member's indexer. An owner on another member is not held, so its incremental build can still publish after the reindex, as the leader's unheld indexer could before.
Tests
--reindex-min-bytesat 512 KiB and catch-up re-sweeps off, small commits to a branch a follower owns stay unindexed, and the commit that crosses the threshold is indexed at its owntthrough the leader. Restoring the leader's commit subscription fails it at the small commits; dropping the follower's publish, disabling member indexing, or triggering before the local apply fails it at the large one.LeaderChangedis classified 503err:db/LeaderChangedwithRetry-After;SnapshotInstalledmaps to it.LeaderChangedruns again. A recorded-outcome test now expects an unsettled error to release the claim. With the old behaviour restored, all three fail.liveness_monitor_demotes_killed_followerchecked that no voter was demoted right after bootstrap, against a 500 ms threshold. With members now indexing, the binary's other clusters starve a voter long enough to be demoted and promoted again, so the precondition waits for the full voter set.Docs
raft-clusters.md: an Indexing section, the CAS table, theapply_index_headroute, the rolling-upgrade window,LeaderChangedand the commit-file cleanup in the submission flow.configuration.md:--indexing-enabledis refused on a cluster member.api/errors.md:err:db/LeaderChanged.design/raft-command-queue.md: indexing follows ownership.Merging into
nextnexthas the same leader-only indexer, plus maintenance holds this PR does not have onmain: a reindex or a purge's erasure holds this instance's indexer and the leader's (hold_indexers,set_leader_indexer). With owners building, an owner on a third member is held by neither, so the port must hold the owning member's builds too, or fence the publish against the hold, before it can land there.next's commit worker also has #2488's waits andindex_afterbelongs before its publish instage_and_advance.Fixes #1768