Skip to content

fix(raft): a never-purged v4.2.0 Raft log survives the upgrade - #2486

Open
bplatz wants to merge 1 commit into
mainfrom
fix/raft-legacy-log-fold-index-0
Open

bplatz wants to merge 1 commit into
mainfrom
fix/raft-legacy-log-fold-index-0

Conversation

@bplatz

@bplatz bplatz commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

When a node first opens a Raft 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. Every release since segments shipped in 4.2.1 does this. A v4.2.0 node that has purged its log is not affected: its run starts above the purge marker.

The fix starts a never-purged log's run at 0. The existing unit test wrote legacy entries from index 1, which openraft never does. a_never_purged_legacy_log_folds_from_index_0 uses the real layout.

raft-clusters.md placed the segment layout in "v4.3". It shipped in 4.2.1. The page now also tells operators to upgrade a node still on v4.2.0 directly to a release with this fix.

The bug was found by the golden v4 Raft fixtures in #2485 (#1689), where a real v4.2.0 node's directory failed to reopen.

Already on next

next has this fix through #2485 (commit 967658d). The fs.rs change, its test and the doc paragraph are identical on both branches, so a main → next merge should resolve them without a conflict. If either PR changes in review, keep next's version when merging. Check that the merge leaves one anchor line and one copy of a_never_purged_legacy_log_folds_from_index_0.

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 in "v4.3"; it shipped in
4.2.1.
@bplatz bplatz added bug Something isn't working as expected area:storage Storage backends, nameservice, ledger lifecycle, index storage, caches labels Nov 22, 2026
@bplatz
bplatz requested a review from a team November 23, 2026 18:19

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

area:storage Storage backends, nameservice, ledger lifecycle, index storage, caches bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant