Repository navigation
Closed as not planned
Labels
area: distributedDistributed coordination and consensuseffort: smallSmall effort - 2-4 hourspriority: mediumImportant but not urgenttype: enhancementNew feature or improvement to existing functionality
Description
Summary
Implement NegotiateConsistency in coordinatorWrapper (cluster.go) and wire it into the FUSE read path before ExecuteOperation (A2-4). This gives the distributed layer a principled consistency level for each read rather than silently making assumptions.
Background
The DistributedCoordinator interface (expanded in A1-2) includes NegotiateConsistency(ctx, key, ConsistencyLevel) (ConsistencyLevel, error). The rules are simple and deterministic, making this a low-risk correctness improvement.
Implementation Rules
| Condition | Return |
|---|---|
| Only one alive node | ConsistencyEventual (no peers to coordinate) |
Caller requests ConsistencyStrong AND this node is NOT leader |
ConsistencySession (downgrade — can't guarantee strong without leader) |
Caller requests ConsistencyStrong AND this node IS leader |
ConsistencyStrong |
| All other cases | Echo the requested level |
func (cw *coordinatorWrapper) NegotiateConsistency(
ctx context.Context,
key string,
requested types.ConsistencyLevel,
) (types.ConsistencyLevel, error) {
aliveCount := cw.cluster.AliveNodeCount()
if aliveCount <= 1 {
return types.ConsistencyEventual, nil
}
if requested == types.ConsistencyStrong && !cw.cluster.IsLeader() {
return types.ConsistencySession, nil
}
return requested, nil
}Wire into FUSE read path (A2-4 integration):
level, _ := fs.coordinator.NegotiateConsistency(ctx, key, types.ConsistencyStrong)
if level == types.ConsistencyEventual {
// peer warmup read is fine
} else {
// require peer to be current leader or skip peer fetch
}Acceptance Criteria
- Unit test covers all three decision cases
- FUSE read path (A2-4) uses negotiated level to decide whether to attempt peer fetch
- Single-node case returns
ConsistencyEventualwithout network calls -
go test -race ./internal/distributed/...passes
Dependencies
- Requires A1-2 (
NegotiateConsistencyadded to interface,ConsistencyLevelpromoted topkg/types) - Requires A2-1 (coordinator wired into FileSystem)
- Requires A2-4 (FUSE read path with peer fetch)
Metadata
Metadata
Assignees
Labels
area: distributedDistributed coordination and consensuseffort: smallSmall effort - 2-4 hourspriority: mediumImportant but not urgenttype: enhancementNew feature or improvement to existing functionality
Activity
scttfrdmn commentedon Aug 3, 2026
Heads-up from the CAS decision on #169: this issue's premise is going away.
The Raft build-out (#128, #130, #133, #151) is closed as not-the-direction; per-key S3 conditional
writes replace it. #284 will delete or redefine the
ConsistencyLeveltaxonomy, and this issue isdefined entirely in terms of its three constants.
The rule table here also depends on the two things #284 is fixing:
StrongAND leader ⇒StrongexecuteStrongConsistencyfans the same PUT with the same bytes to N nodes and calls majority success "strong." There is nothing to promiseStrongAND not leader ⇒ downgrade toSessionSessionandEventualare nearly the same function today — both execute ontargetNodes[0]thenreplicateAsync. The downgrade lands somewhere indistinguishable from where it startedEventualUnder CAS the question a caller is actually asking changes shape: not "which level can you offer
me" but "does this backend support conditional writes" (#282's capability probe) and "do I hold
the lease" (#283). Both are yes/no facts about the world rather than a negotiated level, and both
fail closed — a backend that cannot do conditional writes makes the feature refuse to start rather
than silently downgrade.
So this should be revised or closed as part of #284. Leaving it open and unmilestoned-in-spirit
for now rather than closing unilaterally: if there is a genuine negotiation left after #284 lands, it
belongs here; if not, this closes with #284.
Also note
IsLeader()is load-bearing in the proposed implementation. Leadership survives the CASdecision — #279 got a three-node cluster electing a single leader race-free — but per §2 of
docs/design/conditional-writes-vs-raft.md, a leader that loses network still believes it leads,so
IsLeader()is not safe as a guard on its own. That is exactly the re-assert obligation #283exists to enforce.
scttfrdmn commentedon Aug 8, 2026
Closing as not planned: #284 deleted
ConsistencyLevel, so there is no longer a type for this method to negotiate over. Not a deferral — the thing being negotiated turned out not to exist.Why the type went rather than being cut down.
ConsistencyEventual,ConsistencySessionandConsistencyStrongall issued the same unconditionalPutObject, and differed only in how many nodes issued it and whether the caller waited. So a negotiated level selected the same request either way; the table in this issue would have returned a different string and changed nothing about what happened.And the premise under the table does not hold. Every rule keys on leadership, and leadership confers no read guarantee here. Raft's leader can serve a fresh read because it holds the committed state; these nodes hold no state — the bucket does — and a read goes to S3 the same way from a leader and a follower.
applyLogEntryhas no state machine, so there is nothing a leader is more current about. DowngradingStrongtoSessionon a non-leader was therefore protecting against a staleness that does not arise from leadership, while the staleness that does arise — a peer's cached copy being older than S3 — is not something leadership tells you about either.The residual question is real and belongs to #141. "Should this node fetch this key from a peer's cache, or go to S3?" is a genuine decision, and the answer is a version comparison rather than a consistency level: fetch from the peer if the peer's announced ETag matches what we believe is current, otherwise go to S3.
KeyAnnouncement(#129) already carriesETagfor exactly this. Filing it under cache warming rather than reopening here, because it is a cache-coherence rule and not a consistency-level negotiation, and because it needs the announcement plumbing #141 builds.Two related notes, so nothing is lost with this issue:
CacheInvalidateMessage(gossip.go) is{Key, From}and carries no ETag, so a receiver cannot distinguish an invalidation for a version it has already moved past from one for the version it holds. Tracked as CAS-3: Replace executeStrongConsistency's N-identical-PUT fan-out, and fix the consistency taxonomy #284's remaining R4 half; A1-2: Define richer DistributedCoordinator interface with cache coordination methods #129 has the interface-side note.AliveNodeCount() <= 1 → no network callsis the one rule here that survives on its own merits, and it survives as "do not attempt a peer fetch in a single-node cluster", which A2-3: Hook cache write path — announce to peers and invalidate on S3 write #141's fetch path should check directly.feat(distributed)!: replace the N-identical-PUT fan-out with per-key …