Repository navigation
fix: stop counting a failed distributed operation as a success - #276
Merged
Merged
Conversation
The three consistency executors each reported failure in OperationResult.Success and returned a nil error. ClusterManager.DistributeOperation classified on the error — the ordinary thing to do in Go — so an operation that failed on every node incremented SuccessfulOps. The counters are what an operator reads to decide whether coordination is working. A cluster where every operation fails while the success count climbs is worse than one with no metrics: it actively argues against investigating. ExecuteOperation now returns an error whenever the result is unsuccessful, carrying the result's own failure text so the two representations cannot drift. Reconciled at that one choke point rather than in each executor, because it is the single point every consistency level passes through: a fourth level added later cannot reintroduce the disagreement, and no executor has to remember to report one fact in two places. The -tags=distributed suite that surfaced this was asserting against a misconfiguration. It never injected a backend, so executeLocally took its c.backend == nil arm and every operation failed with "no backend configured" — which is how TestConcurrentOperations came to print "Failed 10 out of 10" and "Successful: 10, Failed: 0" in the same run. Those tests now use a real S3 backend against an in-process substrate endpoint, seed the keys they read, and check the returned bytes rather than only the success flag. A mock on the far side of this seam would agree with the coordinator by construction, which is how the defect was missed. TestClusterManager_DistributedOperation also executes a GET of an absent key, so the tagged suite can now fail if the reconciliation is removed — the assertion its counters could not make while every operation failed for the same reason. Three mutations checked: removing the reconciliation fails the failure-path tests, returning an error unconditionally fails the success-path tests, and dropping the cause from the error text fails the test that reads it. Two further defects found by probe while fixing this and filed as #275: a single-node cluster never elects a leader, because the majority check lives only in the inbound-vote handler, and GetStats reports zero nodes for the first five seconds after Start, because nothing computes the statistics before the ticker first fires. Both are why three tests in that suite have been failing unobserved. Closes #269
scttfrdmn
enabled auto-merge (squash)
August 3, 2026 17:27
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.
The three consistency executors each reported failure in
OperationResult.Successand returned anil error.
ClusterManager.DistributeOperationclassified on the error — the ordinary thing to doin Go — so an operation that failed on every node incremented
SuccessfulOps.The counters are what an operator reads to decide whether coordination is working. A cluster where
every operation fails while the success count climbs is worse than one with no metrics: it actively
argues against investigating.
The fix
ExecuteOperationnow returns an error whenever the result is unsuccessful, carrying the result'sown failure text so the two representations cannot drift.
Reconciled at that one choke point rather than in each executor, because it is the single point
every consistency level passes through: a fourth level added later cannot reintroduce the
disagreement, and no executor has to remember to report one fact in two places. The contract is now
stated in
doc.go— a failed operation is reported both ways, and checking either is sufficient.The test gap in the same change
The
-tags=distributedsuite that surfaced this was asserting against a misconfiguration. It neverinjected a backend, so
executeLocallytook itsc.backend == nilarm and every operation failedwith
no backend configured— which is howTestConcurrentOperationscame to print both of thesein the same run:
Those tests now use a real S3 backend against an in-process substrate endpoint, seed the keys they
read, and check the returned bytes rather than only the success flag. A real backend rather than a
mock, per the harness note in
CLAUDE.md: a mock on the far side of this seam would agree with thecoordinator by construction, which is how the defect was missed.
TestClusterManager_DistributedOperationalso executes a GET of an absent key, so the tagged suitecan now fail if the reconciliation is removed — the assertion its counters could not make while
every operation failed for the same reason.
Verification
Three mutations, each caught:
TestDistributeOperation_FailedOperationCountsAsFailed,TestDistributeOperation_ErrorAndSuccessNeverDisagree(3 failing subtests), andTestClusterManager_DistributedOperationunder-tags=distributedTestDistributeOperation_SucceededOperationCountsAsSuccessful,…NeverDisagree(3 passing subtests)TestDistributeOperation_FailedOperationCountsAsFailed…ErrorAndSuccessNeverDisagreeasserts the invariant itself —result.Success == (err != nil)mustbe false — across all three consistency levels and both outcomes, rather than the two counters that
happen to read it today.
Gates: build, vet, gofmt clean; full
-racesuite green; coverage gate 35 packages at or abovefloor with
internal/distributed73.4% → 73.9%;golangci-lint --new-from-merge-base=origin/main0 issues; gosec unchanged (the two pre-existing
G404atconsensus.go:856,859).Two further defects found while fixing this
Filed as #275, not fixed here. Confirmed by probe rather than by reading:
startElectionsetsvoteCount = 1and themajority check lives only in
handleVoteResponse, which is reached only when a peer replies.With one node there is no peer, so a node that has already satisfied the majority never evaluates
it, and the term increments forever.
GetStatsreports zero nodes for the first five seconds afterStart, because nothingcomputes the statistics before
updateStats' hardcoded ticker first fires — whileGetNodescorrectly reports one.
Both are why three tests in the
-tags=distributedsuite have been failing unobserved. No CI jobbuilds that tag (#240).
Closes #269