Skip to content

fix(raft): a never-purged v4.2.0 Raft log survives the upgrade, pinned by golden v4 fixtures - #2485

Open
bplatz wants to merge 3 commits into
nextfrom
test/raft-v4-golden-fixture
Open

bplatz wants to merge 3 commits into
nextfrom
test/raft-v4-golden-fixture

Conversation

@bplatz

@bplatz bplatz commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

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:

RaftStart(StorageError(... Failed to get log entries, expected index: [10, 12), got [None, None) ...))

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_0 uses the real layout.

The fixtures

fluree-db-consensus/tests/fixtures/raft-v4/ holds the Raft directory, storage and expected.json of a single-voter node from:

  • v4.2.0, the last release that kept one file per log entry;
  • v4.2.9, the last v4 release, whose log is in segments.

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's WorkerPanic for a no-op on the ledger with no commit (#2465).

it_raft_v4_fixture reopens each through this release and checks:

  • the v4 snapshot and the log tail past it;
  • the binding of the v4 ledgers;
  • a query of the ledger;
  • v4's cached receipts and failures answering retries;
  • a new write, a snapshot of this release, and a second restart over it.

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.md put 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 main is #2486.

Fixes #1689

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.
@bplatz bplatz added the bug Something isn't working as expected label Nov 22, 2026
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 branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant