Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ddl: fix reorg info end key after resuming from checkpoint (#52447) #52457

Merged

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #52447

What problem does this PR solve?

Issue Number: close #52411

Problem Summary:

mysql> select count(1) from sbtest1 use index ();
+----------+
| count(1) |
+----------+
|  5000000 |
+----------+
1 row in set (0.58 sec)

mysql> select count(1) from sbtest1 use index (idxc);
+----------+
| count(1) |
+----------+
|  4999999 |
+----------+
1 row in set (0.85 sec)
[2024/04/09 09:53:12.953 +08:00] [ERROR] [reporter.go:274] ["admin check found data inconsistency"] [conn=3848273922] [session_alias=] [table_name=sbtest2] [index_name=idxc] [row_id=5134965]
mysql> select tidb_decode_key('7480000000000000e85f7280000000004e5a75');
+-----------------------------------------------------------+
| tidb_decode_key('7480000000000000e85f7280000000004e5a75') |
+-----------------------------------------------------------+
| {"_tidb_rowid":5134965,"table_id":"232"}                  |
+-----------------------------------------------------------+
1 row in set (0.00 sec)
[2024/04/09 09:40:33.541 +08:00] [INFO] [reorg.go:742] ["[ddl] job get table range"] [jobID=257] [physicalTableID=232] [startKey=7480000000000000e85f728000000000000001] [endKey=7480000000000000e85f7280000000004e5a75]
[2024/04/09 09:40:33.611 +08:00] [INFO] [backfilling.go:398] ["[ddl] split table range from PD"] [physicalTableID=232] ["start key"=7480000000000000e85f728000000000000001] ["end key"=7480000000000000e85f7280000000004e5a75]
[2024/04/09 09:40:33.611 +08:00] [INFO] [backfilling.go:724] ["[ddl] start backfill workers to reorg record"] [type="add index"] [workerCnt=4] [regionCnt=12] [startKey=7480000000000000e85f728000000000000001] [endKey=7480000000000000e85f7280000000004e5a75]
[2024/04/09 09:40:33.658 +08:00] [INFO] [backfilling.go:566] ["[ddl] get backfill range task, change end key"] [id=9] [pTbl=232] ["end key"=7480000000000000e85f72800000000039e153] ["current end key"=7480000000000000e85f72800000000039e153]
...
[2024/04/09 09:40:33.674 +08:00] [INFO] [backfilling.go:566] ["[ddl] get backfill range task, change end key"] [id=12] [pTbl=232] ["end key"=7480000000000000e85f7280000000004e5a75] ["current end key"=7480000000000000e85f7280000000004e5a75]
[2024/04/09 09:40:50.042 +08:00] [INFO] [checkpoint.go:376] ["[ddl-ingest] update checkpoint"] ["job ID"=257] ["index ID"=1] ["local checkpoint"=7480000000000000e85f7280000000004e5a75] ["global checkpoint"=] ["global physical ID"=232] []

-- upgrade and ddl owner switches to new tidb

[2024/04/09 09:42:28.303 +08:00] [INFO] [checkpoint.go:326] ["resume checkpoint"] [category=ddl-ingest] ["job ID"=257] ["index IDs"="[1]"] ["local checkpoint"=] ["global checkpoint"=] ["physical table ID"=232] ["previous instance"=tidb-3-peer:4000:/tmp/tidb] ["current instance"=tidb-1-peer:4000:/tmp/tidb]
[2024/04/09 09:42:28.352 +08:00] [INFO] [backfilling.go:396] ["split table range from PD"] [category=ddl] [physicalTableID=232] ["start key"=7480000000000000e85f728000000000000001] ["end key"=7480000000000000e85f7280000000004e5a75]
[2024/04/09 09:42:28.352 +08:00] [INFO] [backfilling.go:723] ["start backfill workers to reorg record"] [category=ddl] [type="add index"] [workerCnt=4] [regionCnt=12] [startKey=7480000000000000e85f728000000000000001] [endKey=7480000000000000e85f7280000000004e5a75]
[2024/04/09 09:42:28.362 +08:00] [INFO] [backfilling.go:575] ["get backfill range task, change end key"] [category=ddl] [id=1] [pTbl=232] ["end key"=7480000000000000e85f728000000000066aa0] ["current end key"=7480000000000000e85f728000000000066a9f00]
...
[2024/04/09 09:42:28.464 +08:00] [INFO] [backfilling.go:575] ["get backfill range task, change end key"] [category=ddl] [id=12] [pTbl=232] ["end key"=7480000000000000e85f7280000000004e5a75] ["current end key"=7480000000000000e85f7280000000004e5a7400]

Same as #47818, the end key is not considered included. #47818 does not fix this because the end key of reorg info is overwritten in overwriteReorgInfoFromGlobalCheckpoint.

What changed and how does it work?

Adjust end key of reorg info after resuming from checkpoint.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

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

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. type/cherry-pick-for-release-8.1 This PR is cherry-picked to release-8.1 from a source PR. labels Apr 9, 2024
@ti-chi-bot ti-chi-bot added the cherry-pick-approved Cherry pick PR approved by release team. label Apr 9, 2024
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 10, 2024
Copy link

ti-chi-bot bot commented Apr 10, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wjhuang2016, zimulala

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

The pull request process is described here

Needs approval from an approver in each of these files:

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 Apr 10, 2024
Copy link

ti-chi-bot bot commented Apr 10, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-04-10 06:02:28.066083653 +0000 UTC m=+1028609.593624200: ☑️ agreed by wjhuang2016.
  • 2024-04-10 06:17:53.025470572 +0000 UTC m=+1029534.553011115: ☑️ agreed by zimulala.

Copy link

codecov bot commented Apr 10, 2024

Codecov Report

Merging #52457 (c0f48ad) into release-8.1 (9bb3697) will increase coverage by 1.5041%.
Report is 2 commits behind head on release-8.1.
The diff coverage is 46.6666%.

Additional details and impacted files
@@                 Coverage Diff                 @@
##           release-8.1     #52457        +/-   ##
===================================================
+ Coverage      70.6347%   72.1389%   +1.5041%     
===================================================
  Files             1467       1467                
  Lines           408439     426854     +18415     
===================================================
+ Hits            288500     307928     +19428     
+ Misses          100749      99701      -1048     
- Partials         19190      19225        +35     
Flag Coverage Δ
unit 71.0092% <46.6666%> (+1.5498%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 53.9957% <ø> (-2.3014%) ⬇️
parser ∅ <ø> (∅)
br 41.0783% <ø> (-1.6024%) ⬇️

@ti-chi-bot ti-chi-bot bot merged commit 0875379 into pingcap:release-8.1 Apr 10, 2024
18 checks passed
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-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. type/cherry-pick-for-release-8.1 This PR is cherry-picked to release-8.1 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants