Skip to content

Storage: Adapt to ingesting snapshot with irregular region range (release-7.5)#10153

Merged
ti-chi-bot[bot] merged 8 commits intopingcap:release-7.5from
JaySon-Huang:fix_irregular_region_range_75
May 9, 2025
Merged

Storage: Adapt to ingesting snapshot with irregular region range (release-7.5)#10153
ti-chi-bot[bot] merged 8 commits intopingcap:release-7.5from
JaySon-Huang:fix_irregular_region_range_75

Conversation

@JaySon-Huang
Copy link
Contributor

@JaySon-Huang JaySon-Huang commented May 8, 2025

cherry-pick of #10151

What problem does this PR solve?

Issue Number: close #10147

Problem Summary: As the issue describe

What is changed and how it works?

  • Adapt to irregular region range with any suffix, not only "\x00"
  • Refine the irregular region range parsing warning that we can get more information for better diagnosing
    • Turn RowKeyValue(bool is_common_handle_, HandleValuePtr value_) to RowKeyValue::fromHandleWithSuffix(bool is_common_handle_, HandleValuePtr value_)
    • Move the parse warning from parsing RowKeyValue to parsing RowKeyRange::fromRegionRange
Storage: Adapt to ingesting snapshot with irregular region range
If the key format is "t${tableID}_r${handleID1}{AnySuffix}", and `AnySuffix` is not empty, `"t${tableID}_r${handleID1}{AnySuffix}" > "t${tableID}_r${handleID1}"` according to the the comparison semantics of "Key" on TiDB/TiKV.

For example,
If a table is non-clustered, that is with Int64 as the HandleID type.
And the range of a Region is `["xxx_r{handleId1}{AnySuffix}", "xxx_r{handleId2}{AnySuffix}")`, where handleId1 = 100, handleId2 = 200.

If `AnySuffix` is empty, then Region contains the left-closed-right-open range of `[handleID1, handleID2)`
If `AnySuffix` is not empty, then Region contains the range `(handleID1, handleID2]`, which is actually the left-closed-right-open range of `[handleID1+1, handleID2+1)`.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
create table if not exists t (a bigint primary key, b int);
insert into t values (1,2),(2,3),(3,4),(4,5),(20, 50), (21, 51),(200002,2),(200003,3),(200004,4), (9223372036854775807, 101),(9223372036854775806, 100),(-9223372036854775808, -101),(-9223372036854775807, -100);

// The keys is related to the table_id. For these verification cases, the table_id=471

tiup ctl pd -u {pd_ip}:{pd_port} -i
# split with table_id=471, row_id=20, suffix='\x00'
operator add split-region 2077 --policy usekey --keys 7480000000000001FFD75F728000000000FF0000140000000000FB
# then add tiflash replica
alter table set tiflash replica 1;

# split with table_id=471, row_id=20, suffix='\x01'
operator add split-region 2077 --policy usekey --keys 7480000000000001FFD75F728000000000FF0000140100000000FB
# then add tiflash replica
alter table set tiflash replica 1;

# split with table_id=471, row_id=20, suffix='\x0130FF'
operator add split-region 2077 --policy usekey --keys 7480000000000001FFD75F728000000000FF0000140130FF0000FD
# then add tiflash replica
alter table set tiflash replica 1;

# split with table_id=471, row_id=-9223372036854775808, suffix=''
operator add split-region 2077 --policy usekey --keys 7480000000000001FFD75F720000000000FF0000000000000000FA
# then add tiflash replica
alter table set tiflash replica 1;

# split with table_id=471, row_id=-9223372036854775808, suffix='\x01'
operator add split-region 2077 --policy usekey --keys 7480000000000001FFD75F720000000000FF0000000100000000FB
# then add tiflash replica
alter table set tiflash replica 1;

# split with table_id=471, row_id=9223372036854775807, suffix=''
operator add split-region 2077 --policy usekey --keys 7480000000000001FFD75F72FFFFFFFFFFFFFFFFFF0000000000FA
# then add tiflash replica
alter table set tiflash replica 1;

# split with table_id=471, row_id=9223372036854775807, suffix='\x01'
operator add split-region 2077 --policy usekey --keys 7480000000000001FFD75F72FFFFFFFFFFFFFFFFFF0100000000FB
# then add tiflash replica
alter table set tiflash replica 1;
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Fix the issue that TiFlash might panic when handling snapshot with irregular region range

Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels May 8, 2025
@JaySon-Huang JaySon-Huang changed the base branch from master to release-7.5 May 8, 2025 15:39
@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. do-not-merge/cherry-pick-not-approved labels May 8, 2025
@JaySon-Huang
Copy link
Contributor Author

/retest

Signed-off-by: JaySon-Huang <tshent@qq.com>
@JaySon-Huang JaySon-Huang force-pushed the fix_irregular_region_range_75 branch from e81a716 to 7f32645 Compare May 8, 2025 16:00
Signed-off-by: JaySon-Huang <tshent@qq.com>
@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels May 8, 2025
@JaySon-Huang JaySon-Huang changed the title [WIP] Storage: Adapt to ingesting snapshot with irregular region range (release-7.5) Storage: Adapt to ingesting snapshot with irregular region range (release-7.5) May 9, 2025
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 9, 2025
@JaySon-Huang JaySon-Huang added the type/cherry-pick-for-release-7.5 This PR is cherry-picked to release-7.5 from a source PR. label May 9, 2025
@ti-chi-bot ti-chi-bot bot removed the type/cherry-pick-for-release-7.5 This PR is cherry-picked to release-7.5 from a source PR. label May 9, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented May 9, 2025

@JaySon-Huang: You cannot manually add or delete the cherry pick branch category labels. It will be added automatically by bot when the PR is created.

Details

In response to adding label named type/cherry-pick-for-release-7.5.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

Copy link
Member

@CalvinNeo CalvinNeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels May 9, 2025
Signed-off-by: JaySon-Huang <tshent@qq.com>
@JaySon-Huang JaySon-Huang force-pushed the fix_irregular_region_range_75 branch from fd10be7 to da952fd Compare May 9, 2025 08:31
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented May 9, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JinheLin, Lloyd-Pottiger

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [JinheLin,Lloyd-Pottiger]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels May 9, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented May 9, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-05-09 08:16:53.549410209 +0000 UTC m=+87479.697371428: ☑️ agreed by JinheLin.
  • 2025-05-09 08:34:33.703468814 +0000 UTC m=+88539.851430034: ☑️ agreed by Lloyd-Pottiger.

@ti-chi-bot ti-chi-bot bot added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels May 9, 2025
@ti-chi-bot ti-chi-bot bot merged commit 29c9d05 into pingcap:release-7.5 May 9, 2025
4 checks passed
@JaySon-Huang JaySon-Huang deleted the fix_irregular_region_range_75 branch May 12, 2025 01:37
JaySon-Huang added a commit to JaySon-Huang/tiflash that referenced this pull request May 20, 2025
…ease-7.5) (pingcap#10153)

close pingcap#10147

Storage: Adapt to ingesting snapshot with irregular region range
If the key format is "t${tableID}_r${handleID1}{AnySuffix}", and `AnySuffix` is not empty, `"t${tableID}_r${handleID1}{AnySuffix}" > "t${tableID}_r${handleID1}"` according to the the comparison semantics of "Key" on TiDB/TiKV.

For example,
If a table is non-clustered, that is with Int64 as the HandleID type.
And the range of a Region is `["xxx_r{handleId1}{AnySuffix}", "xxx_r{handleId2}{AnySuffix}")`, where handleId1 = 100, handleId2 = 200.

If `AnySuffix` is empty, then Region contains the left-closed-right-open range of `[handleID1, handleID2)`
If `AnySuffix` is not empty, then Region contains the range `(handleID1, handleID2]`, which is actually the left-closed-right-open range of `[handleID1+1, handleID2+1)`.

Signed-off-by: JaySon-Huang <tshent@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved cherry-pick-approved Cherry pick PR approved by release team. lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants