Do not reuse logs that end with an incomplete record#1336
Open
uadhran wants to merge 1 commit into
Open
Conversation
Add Reader::HasIncompleteTrailingRecord to report when EOF discards a partial tail record. Skip WAL and MANIFEST reuse when this flag is set, preventing append from turning a safely discarded fragment into corruption. Related: google#1287
uadhran
marked this pull request as ready for review
June 11, 2026 10:10
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.
Summary
Fixes a corruption risk when
reuse_logsis enabled and a WAL or MANIFEST ends with an incomplete record (writer crashed mid-record). Previouslylog::Readersilently discarded the partial tail, then reuse appended new data — turning a safe discard into likely corruption.Changes
db/log_reader.h/db/log_reader.cc: AddHasIncompleteTrailingRecord(); set when EOF discards truncated header, partial payload, or incomplete fragmented record.db/db_impl.cc: Skip WAL reuse inRecoverLogFilewhen the flag is set.db/version_set.cc: Skip MANIFEST reuse inRecoverwhen the flag is set.db/log_test.cc: Unit tests for complete vs incomplete EOF.db/recovery_test.cc: Integration test that truncated WAL is not reused (reuse_logs).Testing
Linux (CMake Release):
Did not run Windows/macOS builds locally; relies on CI.
Related: #1287