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: Regenerating AutoIDs for _tidb_rowid during Reorganize Partition #53770

Merged
merged 6 commits into from
Jun 13, 2024

Conversation

mjonss
Copy link
Contributor

@mjonss mjonss commented Jun 3, 2024

What problem does this PR solve?

When EXCHANGE PARTITION is used, the _tidb_rowid from the exchanged table, may conflict with rows in other partitions, which can collide during REORGANIZE PARTITION or REMOVE PARTITIONING since they keep the _tidb_rowid but will be placed in the same physical partition/table.

Solution:
Generate new _tidb_rowid for each row during the data reorganization phase.

Issue Number: close #53385

Problem Summary:

What changed and how does it work?

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 bot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 3, 2024
Copy link

tiprow bot commented Jun 3, 2024

Hi @mjonss. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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 kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 3, 2024
@mjonss mjonss requested review from tangenta and Defined2014 June 3, 2024 21:40
Copy link

codecov bot commented Jun 3, 2024

Codecov Report

Attention: Patch coverage is 55.00000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 55.8548%. Comparing base (f1ec74b) to head (8d944e6).
Report is 45 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #53770         +/-   ##
=================================================
- Coverage   74.4865%   55.8548%   -18.6317%     
=================================================
  Files          1506       1629        +123     
  Lines        357921     606377     +248456     
=================================================
+ Hits         266603     338691      +72088     
- Misses        71922     244504     +172582     
- Partials      19396      23182       +3786     
Flag Coverage Δ
integration 37.1762% <55.0000%> (?)
unit 71.4456% <55.0000%> (-1.9152%) ⬇️

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

Components Coverage Δ
dumpling 52.9656% <ø> (-2.2339%) ⬇️
parser ∅ <ø> (∅)
br 49.7779% <ø> (+6.2239%) ⬆️

@mjonss mjonss requested a review from tiancaiamao June 3, 2024 22:01
pkg/ddl/partition.go Outdated Show resolved Hide resolved
// Non-clustered table / not unique _tidb_rowid for the whole table
// Generate new _tidb_rowid if exists.
// Due to EXCHANGE PARTITION, the existing _tidb_rowid may collide between partitions!
stmtCtx := w.sessCtx.GetSessionVars().StmtCtx
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure, will this cause data races between different reorg workers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think each worker w should have its own context and session vars, and which will be used as a cache for the worker, and get globally allocated ids from tables.AllocHandleIDs() which is protected by a lock.

Anyway to verify/test this?

mjonss and others added 2 commits June 11, 2024 00:27
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 11, 2024
@Defined2014 Defined2014 requested a review from zimulala June 11, 2024 02:58
Copy link
Contributor

@zimulala zimulala left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

ti-chi-bot bot commented Jun 13, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Defined2014, 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 approved lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 13, 2024
Copy link

ti-chi-bot bot commented Jun 13, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-06-11 02:58:48.670616278 +0000 UTC m=+433482.723928202: ☑️ agreed by Defined2014.
  • 2024-06-13 03:22:30.584960235 +0000 UTC m=+607704.638272154: ☑️ agreed by zimulala.

@ti-chi-bot ti-chi-bot bot merged commit d5fece2 into pingcap:master Jun 13, 2024
23 checks passed
@mjonss mjonss deleted the fix-35585 branch June 13, 2024 10:41
@YangKeao YangKeao added the needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. label Jul 11, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jul 11, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #54560.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #55052.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Will lose rows after execute remove partitioning on a partition table with exchange partition
5 participants