fix: sync lastLog cache when append config processing fails#6
Draft
anyasabo wants to merge 1 commit into
Draft
Conversation
appendEntries stores new entries before processing configuration records, so a decode failure can leave durable logs ahead of cached lastLog metadata. Update lastLog on this error path and add regression coverage for malformed config-entry processing. Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced May 6, 2026
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.
Problem
appendEntriescan store new entries durably, then fail while processing configuration entry decoding, and return without updating cachedlastLog.Result: durable log advances, but
r.getLastLog()remains stale.How this can happen in concrete terms
AppendEntriescontaining at least one config-changing entry.StoreLogs.lastLogupdate step.This produces a cache/store mismatch even though append persistence already succeeded.
Mitigations that help
But pre-fix, once this error path was hit, cache divergence still occurred.
Impact
Availability/liveness degradation risk after an error event:
How we would notice in production
failed to append entry ... failed to decode peers(or decode config).last_log_*and on-disk state immediately after failure.Provenance / Preconditions
e59f65d6, 2021).StoreLogssucceeds,What this PR changes
lastLogto the newly stored last entry before returning.Reviewer reproduction (live in-process path)
Reproduce pre-fix behavior
git checkout 53b8474^git checkout fix/append-config-process-failure-lastlog -- raft_test.gogo test -run "TestRaft_AppendEntriesConfigProcessFailureRefreshesLastLog" -count=1 .lastLogassertion failure.Verify fixed behavior
fix/append-config-process-failure-lastlog).go test -run "TestRaft_AppendEntriesConfigProcessFailureRefreshesLastLog" -count=1 .lastLogaligns with durable store after error.Test plan
go test -run "TestRaft_AppendEntriesConfigProcessFailureRefreshesLastLog" -count=1 .go test -run "TestRaft_AppendEntry$|TestRaft_AppendEntriesConfigProcessFailureRefreshesLastLog" -count=1 .