Repository navigation
fix(storage): throw instead of crashing on torn WAL tail reads - #1522
Merged
Merged
Conversation
BufferedFileReader::read copied the full requested size after a page refill without checking that the final page held that many bytes, so a WAL truncated mid-record (ENOSPC, power loss, SIGKILL mid-commit) overran the heap buffer and crashed recovery with SIGSEGV/SIGBUS in both strict and lenient modes. Loop small reads across page boundaries and pre-validate large reads against the file size, so torn tails surface as catchable replay errors: strict mode throws and lenient mode drops the torn transaction. Add WalTest.TornWALTailInsideLargeStringRecord covering a mid-string truncation of a multi-page WAL in both modes. Backport of 423dbf7 to release_0_22 (without the checkpoint_test.cpp build fix, which is not needed on this branch).
adsharma
force-pushed
the
fix/torn-wal-replay-crash-0.22
branch
from
November 6, 2026 16:32
199b071 to
b9a04da
Compare
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.
Backport of #1520 to release_0_22 (identical buggy code on this branch).
A WAL truncated mid-record (ENOSPC, power loss, SIGKILL mid-commit) crashed recovery with SIGSEGV/SIGBUS in both strict and lenient modes:
BufferedFileReader::readcopied the full requested size after a page refill without checking the short final page, overrunning the heap buffer insideWALRecord::deserialize <- dryReplay.This loops small reads across page boundaries and pre-validates large reads against the file size, so torn tails surface as catchable replay errors: strict mode throws, lenient mode drops the torn transaction.
Adds
WalTest.TornWALTailInsideLargeStringRecordcovering a mid-string truncation of a multi-page WAL in both modes.