Repository navigation
Description
Summary
Evaluate whether S3 conditional writes (If-None-Match / If-Match) can provide the
coordination guarantees the internal/distributed package is being built toward, at a fraction
of the complexity. This is a design evaluation, not a commitment to re-scope: nothing in
v0.11.0-v0.13.0 changes unless this produces evidence that it should.
Filed against v0.11.0 deliberately — the evaluation is only useful before more consensus code
is written.
Background
The evaluation should start from what the distributed package actually does today, which is
narrower than the roadmap and package docs imply. Findings from the v0.10.0 review:
There is no state machine. applyLogEntry in internal/distributed/consensus.go is three
empty arms:
switch entry.Type {
case EntryTypeOperation:
// Apply operation to state machine
case EntryTypeConfigChange:
// Apply configuration change
case EntryTypeNoop:
// No operation
}Nothing anywhere appends EntryTypeOperation or EntryTypeConfigChange. The log holds one
bootstrap noop plus one entry per election win. The consensus layer elects leaders and
replicates nothing.
Consensus is not on the data path. Coordinator.executeLocally calls the backend directly
and never consults the log, commitIndex, term, or leadership.
"Strong consistency" is not linearizable. executeStrongConsistency fans an operation to N
nodes and succeeds on successCount >= len(targetNodes)/2+1. But every node writes the same
S3 key, so these are N redundant identical PUTs. Majority success is a reachability signal, not
a consistency guarantee. doc.go claims linearizability; the code does not support it.
broadcastProposal is a simulation stub that sleeps and self-accepts. selectConsistentHash
returns nodes[:count] — no hashing.
So the comparison is not "replace working Raft with conditional writes." It is "choose the
mechanism before building the thing," which is a much cheaper decision to make now.
Implementation
Produce a written evaluation covering:
-
Which guarantees are actually needed. Distinguish what the filesystem requires
(single-writer-per-key, atomic metadata updates, cache invalidation ordering) from what Raft
provides. If S3 is the sole source of truth and every node writes the same keys, the useful
primitive may be per-key CAS rather than a replicated log. -
What conditional writes can and cannot do.
If-None-Match: *gives atomic
create-if-absent;If-Match: <etag>gives compare-and-swap on update. Both are per-object.
They cannot provide multi-key atomicity, leader election with liveness guarantees, or
membership consensus. Be explicit about where that ceiling bites. -
The interface change required.
Backend.PutObjectinpkg/types/interfaces.gotakes no
precondition and returns no ETag, and there are zero hits forIf-None-Match/If-Match
repo-wide. ETags are already plumbed for reads (types.ObjectInfo.ETag, populated in
HeadObjectandListObjects), so the read half exists. Scope the write-side change. -
Non-AWS compatibility. Conditional write support varies across MinIO, Ceph, and Wasabi.
Since the metadata fallback path in the v0.14.0 work exists precisely for those backends,
establish what degrades and how. -
A recommendation with enough specificity to act on: keep the Raft direction, replace it,
or adopt a hybrid (CAS for per-key coordination, gossip for membership, no replicated log).
Acceptance Criteria
- Written evaluation covering all five points above, committed under
docs/ - Explicit statement of which guarantees the filesystem needs versus which Raft provides
- Concrete API sketch for the
Backendprecondition/ETag change - Compatibility matrix for AWS, MinIO, Ceph, and Wasabi
- A recommendation, with the issues that would be opened or closed if adopted
-
doc.go's linearizability claim corrected either way — it is inaccurate today regardless
of which direction is chosen - No code changes in this issue
Dependencies
None. Should be done early: its value decreases as more consensus code is written.
Activity
scttfrdmn commentedon Aug 3, 2026
Evaluation complete — PR #265, document at
docs/design/conditional-writes-vs-raft.md.Recommendation: adopt the hybrid. Per-key compare-and-swap for coordination, gossip for
membership, no replicated log. Stop building toward Raft.
The one-line reason: Raft replicates a log so N nodes agree on state they each hold a copy of.
ObjectFS nodes hold no such state — S3 does. Every operation
internal/distributedcoordinates endsin a write to a key in one bucket every node can already read, so a protocol whose purpose is
agreeing on a replicated state machine has nothing to replicate.
The premises in this issue all hold, verified against source rather than taken on trust:
applyLogEntryis three empty arms with no caller appendingEntryTypeOperation;executeLocallycalls the backend directly, never consulting the log, commit index, term, or leadership;
executeStrongConsistencyfans N identical PUTs of the same bytes at one key and accepts on amajority, which is a reachability signal rather than linearizability.
The CAS primitive is proven by execution, not inferred from AWS documentation. Substrate v0.85.0
implements conditional writes (from substrate#397) with a 64-stripe per-key mutex held across
check→Put, so an exactly-one-winner result is meaningful rather than an artifact of last-write-wins.
Over real HTTP: 32 concurrent
If-None-Match: *PUTs → exactly 1 winner; staleIf-Match→ 412with the object unchanged;
If-Matchon an absent key →NoSuchKey, not 412; 8 workers in aread-ETag → increment → CAS loop converge to exactly 8 with zero lost updates; and
PutObjectreturns a fresh ETag, so a CAS loop needs no HEAD between iterations.
Two findings this issue did not anticipate, both changing caller code:
ConditionalRequestConflict= a delete interleaved; aPutObjectmay be retried as-is, but aCompleteMultipartUploadhas a dead upload ID and must restart fromCreateMultipartUpload. Aloop conflating them spins until it gives up — and substrate models only 412, so that bug is
invisible in testing today. Filed upstream as S3: conditional writes never return 409 Conflict, so the retry path a caller must take is untestable substrate#540.
fail closed. An unconditional fallback turns "exactly one node performs this tier transition"
into "every node does" — the failure the coordination exists to prevent, occurring silently.
Detection by attempt, not by configuration: a backend that succeeds at an
If-Matchprobeagainst a known-absent key is silently ignoring preconditions, which a feature flag would never
notice.
The ceiling (§2 of the doc, the part to read before agreeing): no multi-key atomicity, and no
liveness guarantee on leadership — from which follows the design obligation that every guarded
action must re-assert the CAS, because an action guarded by "I checked my lease a moment ago" is
not guarded. Raft fails closed on quorum loss; CAS fails closed only if the guarded action
re-checks. Cost is per-attempt, since AWS bills failed conditional requests at normal rates.
Issue consequences, for your call — I have not closed anything. If accepted: close #128, #130
(currently
priority: critical, and the largest single saving), #133 (the gossip networkingsurvives, the proposal framing does not), #151. Keep #131 (needed more, not less — work
distribution is how contention on coordination keys stays low), #132, #206. Open four:
PutObjectIfplus sentinels and the probe · the lease type with the re-assert rule · replace
executeStrongConsistency's fan-out and fix the consistency-level taxonomy · verify MinIO andWasabi against real endpoints.
Merge origin/main: fold #267's Fixed entry in beside #169's
scttfrdmn commentedon Aug 3, 2026
Decision: adopted
The recommendation in
docs/design/conditional-writes-vs-raft.mdis adopted. Per-key S3conditional writes (CAS) replace the Raft build-out as ObjectFS's coordination primitive; gossip
remains the membership mechanism.
Closed as not-the-direction:
ConsensusLogapplyLogEntryis three empty arms and nothing appendsEntryTypeOperationPersistentStatepriority: criticalone. Nodes hold no authoritative state, so the hardest correctness obligation in the Raft direction does not exist in the otherbroadcastProposalSnapshotOpened:
Backend.PutObjectIf+Precondition+ the two sentinels + the S3 implementation + the capability probe. Blocks the restexecuteStrongConsistency's N-identical-PUT fan-out; delete or redefine the consistency taxonomyKept, unchanged: #132 (gossip stats), #206 (gossip authentication — a real security defect either
way). #131 (rendezvous hashing) has already landed, so
selectConsistentHashis a real HRW ring andno longer
nodes[:count].Two corrections to §5 of the doc, for the record
BboltPersistentState/BboltConsensusLog).Its own Background states the dependency: "The
ConsensusLogandPersistentStateinterfaceswere defined in A1-1 and A1-3" — i.e. A1-1: Define ConsensusLog interface and in-memory implementation #128 and A1-3: Add PersistentState interface — Raft safety prerequisite #130, both now closed. There is nothing left for
it to implement. It is still open because it was not among the four in the approved set;
flagging rather than assuming.
doc.goitem is already done. §5 lists correcting the "Linearizable operations acrosscluster" claim as owed regardless of direction; grep for
Linearizablenow returns nothing.Also worth noting for whoever picks up #284:
ConsistencySessionandConsistencyEventualarenow nearly the same function — both execute on
targetNodes[0]and thenreplicateAsynctheremainder. Session's only distinguishing feature is a comment promising it will "try to use the same
node for related operations," and there is no session state anywhere to make that true. So the
taxonomy offers three names for two behaviours, one of which (§1) is mislabeled.
docs: record the CAS decision where the code claims otherwise (#286)
docs: the Raft closure list is five, not four (#287)
fix: a cluster node whose status this build doesn't recognize
lint: range over integers, and stop linting a dependency's Go files (#…
feat(s3): a write that happens only if an assertion about the key hol…