[BugFix] Fix BE crash in primary key auto-increment partial update apply (backport #76119)#76176
Closed
mergify[bot] wants to merge 1 commit into
Closed
[BugFix] Fix BE crash in primary key auto-increment partial update apply (backport #76119)#76176mergify[bot] wants to merge 1 commit into
mergify[bot] wants to merge 1 commit into
Conversation
Contributor
Author
|
Cherry-pick of ce03ba6 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
23 tasks
Contributor
Author
|
@mergify[bot]: Backport conflict, please reslove the conflict and resubmit the pr |
auto-merge was automatically disabled
July 10, 2026 06:11
Pull request was closed
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.
Why I'm doing:
For a primary-key table with an AUTO_INCREMENT column, a partial update that
omits that column applies through SegmentRewriter::rewrite_auto_increment, which
rebuilds the full segment from three sources: the keys / user-provided columns
re-read from the partial segment, the auto-increment column, and the missing
columns read from history.
rewrite_auto_increment swallowed the status of the partial-segment read: the
iterator was taken with StatusOr::value() (no ok() check) and get_next's status
was dropped (only a DCHECK guarded the row count, compiled out in release). A
transient read failure left read_chunk short, so the rebuilt segment recorded a
segment num_rows of 0 while its value columns still held N rows of real data.
The rowset meta and primary index kept the commit-time counts, so the
inconsistency stayed dormant until a later partial update of the same keys read
that segment via get_column_values, which silently skipped the 0-row segment,
returned an empty read column, and dereferenced a null source in
append_selective / SIMDGather (src=0x0) -- a crash that replays the pending
apply on every restart.
Shared-nothing only; the lake path (rewrite_auto_increment_lake)
already checks the read.
What I'm doing:
Root cause (write side), be/src/storage/rowset/segment_rewriter.cpp:
with ASSIGN_OR_RETURN (an iterator-creation failure now returns cleanly
instead of aborting in value()), propagate get_next's status, and always
validate the read row count against the segment, with the expected/actual
counts and segment path in the error. This mirrors rewrite_auto_increment_lake.
Also closes a latent crash where itr->close() ran on a possibly-null iterator.
Read side (stops the crash on already-corrupt data),
be/src/storage/tablet_updates.cpp:
a resolved rssid points to a 0-row segment (both the main read loop and the
auto-increment default block). Corruption is non-retryable, so the tablet
enters error state (recoverable via clone) rather than an endless crash-loop.
Generalizes [BugFix] Guard against iterator UB in get_column_values when rssid not found #69617, which only guarded the rssid-underflow / out-of-range case.
Fixes #issue
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check:
This is an automatic backport of pull request #76119 done by [Mergify](https://mergify.com).