This repository was archived by the owner on Oct 25, 2026. It is now read-only.
Repository navigation
Conversation
When a disk-based full sync is transcoded, bytes that follow the end of the source VCS frame are left pending in the push reader. rdbTranscoderRun() then returns success, and the next write feeds the reader again while it still holds them, which trips serverAssert(len == 0 || !resuming) in streamPushReaderFeed() and crashes the replica. If the trailing bytes instead arrive in the final write they are silently dropped. A well-formed payload never has bytes after the frame: the receiver strips the $EOF mark before feeding the transcoder and the primary writes a single frame. Treat trailing bytes as a malformed payload and fail the transcode, so the replica aborts the sync and retries instead of crashing. Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
During a disk-based full sync that transcodes the RDB (wire codec differs from the replica's
rdbcompression), any bytes after the end of the primary's VCS frame are left pending in the push reader, and the next transcoder write tripsserverAssert(len == 0 || !resuming)and crashes the replica. A well-formed payload never has such bytes, so this is reachable only with a malformed or corrupted payload, but it should fail the sync, not the process. This fails the transcode when the frame ends with input left over, so the replica aborts the sync and retries.AI generated details
Problem
rdbTranscoderRun()breaks out of its feed loop onSTREAM_PUSH_READER_FRAME_DONE(src/rdb_transcoder.c:141), on the assumption stated in its comment that the caller already excluded trailing bytes.streamPushReaderFeed()stashes whatever follows the frame end inpending_input(src/compression_stream.c:616-618). After the frame ends the decompressor consumes nothing (src/compression.c:161), so later input is stashed too. The next feed with input then asserts atsrc/compression_stream.c:593.Base
8f67ab136, LZ4 source, plaintext target:serverAssertcrashreplicaReceiveRDBFromPrimaryToDisk()callsrdbTranscoderWrite()once per read for size-framed transfers and up to twice per read for$EOF-marked ones (src/replication.c:3199-3210), so trailing bytes that span a read boundary reach the crash. The verbatim route (source codec equals target) never decodes; it still writes trailing bytes to disk, where the loader stops at the frame end and ignores them.Introduced in #4749 (
7fe7ca45fon unstable,4216cddd7on 9.2). Not in any release tag.Can a well-behaved primary send trailing bytes?
No. The receiver holds back the trailing
RDB_EOF_MARK_SIZEbytes, so the$EOFmark is never fed (src/replication.c:3193-3214). The primary writes exactly one codec frame per RDB (rdbSaveRio(),src/rdb.c:1675), and the diskless$EOFtrailer is written after it returns and the writer is detached (src/rdb.c:1631).Alternative considered
Ignore the trailing bytes instead of failing. The on-disk loader stops at the frame end (
CompressionTest.streamReaderStopsBeforeTrailingBytes), so the verbatim route already tolerates them. That loses: nothing legitimate produces them, the transcoder's own contract says there are none, and it needs a frame-done flag plus discarding pending input on every later write rather than one check. Failing the sync costs a retry on a payload that is already wrong.Behavior change
Trailing bytes that arrive with the frame end used to be dropped and the sync succeeded. They now fail the sync. Only malformed payloads are affected.
Testing
CompressionTest.rdbTranscoderRejectsBytesAfterSourceFrameinsrc/unit/test_compression.cppdrives the transcoder directly for every source/target pair that converts, with the trailer in the frame's write and split across two later writes. There were no unit tests for the transcoder before. With thesrc/rdb_transcoder.chunk reverted:The second trailer write then dies in the assert:
This was generated by AI but verified, with love, by a human.