[BugFix] Cover projected sstable max_rss_rowid in update_next_rowset_id (backport #72172)#72342
Merged
Merged
Conversation
24 tasks
xiangguangyxg
approved these changes
Apr 29, 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.
Why I'm doing:
Repeated SPLIT/MERGE cycles on a shared-data range-distribution PK table get stuck because a background COMPACTION publish on a SPLIT child fails with "sstables are not ordered" — and the next reshard job parks in
PREPARINGwaiting for the publish to finish.What I'm doing:
merge_sstables(be/src/storage/lake/tablet_merger.cpp:615-618) projects each child's sstablemax_rss_rowidby addingctx.rssid_offsetto the high word. The legacy non-shared_rssidbranch can produce a projected high that exceeds everyrowset.idin the merged metadata — for example, a delete-only sstable whose memtable max_rss_rowid was set to(rowset_id<<32|UINT32_MAX)(be/src/storage/lake/persistent_index_memtable.cpp:110, 131) contributes a high rssid that has no surviving rowset to pin it.update_next_rowset_idwalked onlymetadata->rowsets(), so the merged tablet'snext_rowset_idwas set fromrowset.idalone. Any subsequent write on this tablet — and on every SPLIT child that inherits this metadata viastd::make_shared<TabletMetadataPB>(*old_tablet_metadata)insplit_tablet(be/src/storage/lake/tablet_splitter.cpp:486) — would assign a new rssid less than the projected sstable highs, producing a sstable whosemax_rss_rowidfalls below an existing entry insstable_meta. That breaks the ascending-order invariantLakePersistentIndex::commit()enforces (be/src/storage/lake/lake_persistent_index.cpp:881):The COMPACTION transaction whose publish triggered the check parks in
COMMITTED. The next reshard job on the same tablet allocates itscommitVersionviagetNextTransactionId()and waits inPREPARINGforvisibleVersionto catch up (MergeTabletJob.runPreparingJob), but the stuck compaction blocks the publish chain — soPREPARINGhangs indefinitely and the table is parked inTABLET_RESHARD.Reproducer (shared-data PK range distribution, 3-CN cluster)
SPLIT 1->8, UPSERT, MERGE 8->1, SPLIT 1->8, UPSERT, MERGE 8->1, ...MERGE_TABLETjob sits inJOB_STATE=PREPARING;SHOW PROC "/transactions/<db>/running"shows theCOMPACTION_…txn parked inCOMMITTED, and the table state stays inTABLET_RESHARD.Fix
In
update_next_rowset_idalso walksstable_meta.sstables(*)and boundnext_rowset_idby(max projected high) + 1, clamping atUINT32_MAXto match the rssid encoding. Future writes — including those on any SPLIT child inheriting this metadata — are guaranteed to assign rssids strictly greater than every projected sstable high, so new sstables append tosstable_metain ascendingmax_rss_rowidorder.Fixes #64986
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 [BugFix] Cover projected sstable max_rss_rowid in update_next_rowset_id #72172 done by Mergify.