Repository navigation
Closed as not planned
Labels
area: distributedDistributed coordination and consensuseffort: largeLarge effort - 3-5 dayspriority: highImportant issue that should be addressed soonresolution: wontfixWill not be fixed/implementedtype: enhancementNew feature or improvement to existing functionality
Description
Summary
Add go.etcd.io/bbolt to go.mod and implement persistent Raft storage (BboltConsensusLog, BboltPersistentState) in internal/distributed/log/bbolt.go. This is the production Raft safety upgrade: node restarts no longer violate Raft's durability guarantees.
Background
The ConsensusLog and PersistentState interfaces were defined in A1-1 and A1-3 with in-memory defaults. This issue swaps in durable bbolt-backed implementations. The interface is already in place — no other packages change.
Implementation
New file: internal/distributed/log/bbolt.go
// BboltConsensusLog implements ConsensusLog backed by bbolt.
// Log entries are keyed by big-endian uint64 index for ordered iteration.
type BboltConsensusLog struct {
db *bbolt.DB
bucket []byte
mu sync.RWMutex
}
// BboltPersistentState implements PersistentState backed by bbolt.
// SaveTerm writes term+votedFor atomically in a single transaction.
type BboltPersistentState struct {
db *bbolt.DB
bucket []byte
}Default data path:
${OBJECTFS_DATA_DIR:-/var/lib/objectfs}/<node-id>/raft.db
Enabled by config:
cluster:
persistent_log: true # default: false
data_dir: /var/lib/objectfsWhen persistent_log = false (default), MemoryLog and MemoryPersistentState are used — existing behavior unchanged.
Key implementation details:
- Log entries keyed as 8-byte big-endian uint64 (ensures lexicographic = numeric order in bbolt)
SaveTermwrites term + votedFor in a single transaction (atomicity requirement)TruncateSuffix(index)deletes all keys > index in one transactionSlice(lo, hi)uses a cursor for efficient range reads
New dependency
go get go.etcd.io/bbolt
Acceptance Criteria
-
TestBboltRoundTrip: open DB, append 100 entries, close, reopen, verify all 100 present with correct index/term/data -
TestPersistentStateSurvivesRestart: write term+votedFor, construct newBboltPersistentStateon same DB, verifyLoadTermreturns same values -
TestBboltTruncateSuffix: append 50 entries, truncate at 25, verify only 25 remain -
go test -race ./internal/distributed/log/...passes - When
persistent_log = false, only in-memory impls are instantiated (no bbolt dep loaded)
Dependencies
- Requires A1-1 (
ConsensusLoginterface ininternal/distributed/log/interface.go) - Requires A1-3 (
PersistentStateinterface; injection intoConsensusEngine)
Metadata
Metadata
Assignees
Labels
area: distributedDistributed coordination and consensuseffort: largeLarge effort - 3-5 dayspriority: highImportant issue that should be addressed soonresolution: wontfixWill not be fixed/implementedtype: enhancementNew feature or improvement to existing functionality
Activity
scttfrdmn commentedon Aug 3, 2026
This issue's dependencies were closed on 2026-08-03 and it is now unimplementable as written. Flagging rather than closing, because it was not in the approved closure set — see below.
The CAS recommendation in #169 /
docs/design/conditional-writes-vs-raft.mdwas adopted. The Raft build-out is closed: #128 (ConsensusLog), #130 (PersistentState), #133 (proposal broadcast), #151 (log compaction).This issue's own Background names its dependency exactly:
A1-1 is #128 and A1-3 is #130. Neither interface is going to exist, so there is nothing here to back with bbolt. Two further reasons it does not survive in reduced form:
go.etcd.io/bbolttogo.modand a${OBJECTFS_DATA_DIR:-/var/lib/objectfs}/<node-id>/raft.dbdata path. CAS needs neither: coordination state is an object in the bucket guarded byIf-Match/If-None-Match, so there is no local durability requirement and no new dependency.Why still open: the direction decision authorized closing four specific issues (#128, #130, #133, #151). §5 of the design doc omitted #150 from its closure list — an omission in the doc, which I have corrected in the doc itself and noted on #169 — so closing it would be extending the approved scope on my own inference. It needs an explicit call. My recommendation is to close it as
resolution: wontfixalongside the other four.It is also still on the v0.13.0 milestone, whose title I have changed from "Cache Warming, Raft Persistence & Operational Excellence" to "Cache Warming & Operational Excellence" — this issue and #151 were the "Raft Persistence" part.
docs: record the CAS decision where the code claims otherwise (#286)
scttfrdmn commentedon Aug 3, 2026
Closing as not-the-direction, per the CAS decision on #169 — confirmed explicitly, since this issue was outside the originally approved closure set.
The reasoning is in the comment above: this issue's own Background states "The
ConsensusLogandPersistentStateinterfaces were defined in A1-1 and A1-3 with in-memory defaults. This issue swaps in durable bbolt-backed implementations." A1-1 is #128 and A1-3 is #130, both closed as not-the-direction, so there is nothing left to back with bbolt. It would also have addedgo.etcd.io/bboltand a/var/lib/objectfsdata path that the CAS direction does not need — coordination state is an object in the bucket guarded byIf-Match/If-None-Match, so there is no local durability requirement.Closed alongside #128, #130, #133 and #151. The v0.13.0 milestone has been retitled from "Cache Warming, Raft Persistence & Operational Excellence" — this issue and #151 were the Raft Persistence.
docs: the Raft closure list is five, not four (#287)