HBASE-30230 Reject truncate_preserve on tables with overlapping regions - #8534
Open
terrytlu wants to merge 1 commit into
Open
HBASE-30230 Reject truncate_preserve on tables with overlapping regions#8534terrytlu wants to merge 1 commit into
terrytlu wants to merge 1 commit into
Conversation
When truncate_preserve is executed on a table with overlapping regions (multiple regions sharing the same startKey), the procedure gets stuck indefinitely. During truncate, regions are cleaned and recreated at the same timestamp, producing regions with identical encodedNames (derived from tableName + startKey + regionId). The duplicate encodedNames cause race conditions in subsequent procedure steps (e.g. TRUNCATE_TABLE_CREATE_FS_LAYOUT or REGION_STATE_TRANSITION_CONFIRM_OPENED), and recovery requires manual metadata repair with HBCK2. Region overlaps are unavoidable in production (they can result from interrupted split operations). Instead of proceeding into an unrecoverable stuck state, this change adds a pre-check in the TRUNCATE_TABLE_PRE_OPERATION state: when preserveSplits=true, TruncateTableProcedure now detects duplicate startKey regions via checkRegionsStartKeyNoDuplicate() and fails the truncate with a clear HBaseIOException message, telling the operator to fix the region overlap first. Tests added in TestTruncateTableProcedure cover preserveSplits=true failing on duplicate/overlapping regions, and preserveSplits=false still succeeding (single new region, no encodedName collision). Signed-off-by: terrytlu <terrytlu@tencent.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 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.
When truncate_preserve is executed on a table with overlapping regions (multiple regions sharing the same startKey), the procedure gets stuck indefinitely. During truncate, regions are cleaned and recreated at the same timestamp, producing regions with identical encodedNames (derived from tableName + startKey + regionId(timestamp)). The duplicate encodedNames cause race conditions in subsequent procedure steps (e.g. TRUNCATE_TABLE_CREATE_FS_LAYOUT or
REGION_STATE_TRANSITION_CONFIRM_OPENED), and recovery requires manual metadata repair with HBCK2.
Region overlaps are unavoidable in production (they can result from interrupted split operations). Instead of proceeding into an unrecoverable stuck state, this change adds a pre-check in the TRUNCATE_TABLE_PRE_OPERATION state: when preserveSplits=true, TruncateTableProcedure now detects duplicate startKey regions via checkRegionsStartKeyNoDuplicate() and fails the truncate with a clear HBaseIOException message, telling the operator to fix the region overlap first.
Tests added in TestTruncateTableProcedure cover preserveSplits=true failing on duplicate/overlapping regions, and preserveSplits=false still succeeding (single new region, no encodedName collision).