Repository navigation
Conversation
openraft writes a cluster's first membership entry at index 0, but the
fold of per-entry log files into a segment anchored a log with no purge
marker at index 1. On a v4.2.0 node that had never purged its log the
contiguous run came out empty, so no segment was written, every entry
file was then deleted, and the node failed to start ("Failed to get log
entries, expected index: [10, 12)"). Entries past the last snapshot were
lost. Anchor a never-purged log at 0.
raft-clusters.md placed the segment layout and name bindings in "v4.3":
segments shipped in 4.2.1 and bindings in 5.0.
Fixtures written by real single-voter nodes: v4.2.0, the last release that kept one file per log entry, and v4.2.9, the last v4 release, whose log is in segments. Each holds two ledgers (one created and never committed), keyed receipts before and after a snapshot so the log has a tail past it, a keyed submission that failed to stage, and v4's WorkerPanic for a no-op on the ledger with no commit. generate.rs is the test that wrote them, run inside an exported v4 tree. it_raft_v4_fixture reopens each through this release: the v4 snapshot and log tail, binding of the v4 ledgers, a query, v4's cached receipts and failures answering retries, a new write, a snapshot of this release and a second restart over it.
A long-running v4 node has purged its log through its snapshot. Each fixture now also comes as a log purged that way: a purge marker and only the tail past the snapshot. The never-purged v4.2.0 log is the one the index-0 fold fix is for; the purged one opened before it too.
This was referenced Nov 22, 2026
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.
Adds golden on-disk fixtures for v4 Raft nodes and the reader test #1689 asked for. Its first run found an upgrade bug, which this also fixes.
The bug
When a node first opens a log written in the one-file-per-entry layout (v4.2.0), it folds the entries into a segment. The fold keeps the contiguous run above the purge cutoff, and with no purge marker it started that run at index 1. openraft writes a cluster's first membership entry at index 0. So on a v4.2.0 node that had never purged its log, the run came out empty: no segment was written, every entry file was then deleted, and the node failed to start:
Committed entries past the last snapshot are gone from that node. Without a snapshot, that is the whole replicated log. This has been the case since segments shipped in 4.2.1: a v4.2.9 node opening the same v4.2.0 directory fails the same way and leaves its
log/empty. The fix starts a never-purged log's run at 0. The unit test the fold had wrote its entries from index 1, which openraft never does;a_never_purged_legacy_log_folds_from_index_0uses the real layout.The fixtures
fluree-db-consensus/tests/fixtures/raft-v4/holds the Raft directory, storage andexpected.jsonof a single-voter node from:Each comes in two forms: a log never purged, and, under
-purged, one purged through its snapshot, as a long-running node's is. The purged v4.2.0 log opened even with the old fold, so the bug is limited to v4.2.0 nodes that never purged.Each was written by real v4 code, by the test in
generate.rs, run inside an exported tree of that tag. Each holds two ledgers, one created and never committed. It also holds keyed receipts before and after a snapshot, so the log has a tail past it, a keyed submission that failed to stage, and v4'sWorkerPanicfor a no-op on the ledger with no commit (#2465).it_raft_v4_fixturereopens each through this release and checks:Every other storage and consensus test writes with the code that reads, so this is the test that notices a change to the replicated encoding that v4 data can't decode under. #2465 and #1741 both change that encoding.
Docs
raft-clusters.mdput the segment layout and name bindings in "v4.3". Segments shipped in 4.2.1 and bindings in 5.0. It now also says to upgrade a node still on v4.2.0 directly to a release with this fix.The same fix for
mainis #2486.Fixes #1689