Skip to content

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #60132

What problem does this PR solve?

Issue Number: close #59680

Problem Summary:
Issue is that for non-clustered, partitioned tables and REORGANIZE PARTITION (and related alters).
And possibility of EXCHANGE PARTITION, which allows duplicate _tidb_rowid's between partitions.
And the new reorganized set of partitions are not kept in-sync with the old non-reorganized partitions.

What changed and how does it work?

Original issue was #53385. After trying both "Always generate a new _tidb_rowid", (#53770, leading to #57510) and "using AddRecord", to generate new _tidb_rowid's (#57114, leading to #59680) and having the indexes up-to-date (for the currently used set of partition), there will always be issues between the original set of partitions and the reorganized set of partitions, due to not being in sync / having the same _tidb_rowid.

This solution will make sure that if a row exists in both sets of partitions, it will always have the same _tidb_rowid.

It works like this:
During backfill, if a the currents row's tidb_rowid already exists in the new partition:
If same row (content is same as current row)

  • Skip backfilling it (since already there)
    else
  • generate a new table unique _tidb_rowid and delete the current row and add it back with the new _tidb_rowid and save the same row, with the new _tidb_rowid in the new partition.

During DML:
Delete: Only delete the reorganized row if it matches both _tidb_rowid AND row content
Update: Use DELETE+INSERT (RemoveRecord+AddRecord) where DELETE is the same as above. When insert/AddRecord creates a new _tidb_rowid, use that newly generated id for both new and old partitions.
And INSERT: if moving between partitions in the current set of partition, then a new unique _tidb_rowid will be generated, so use that the other set of partitions as well. Else if the _tidb_rowid already exists in the other set of partitions, then generate a new _tidb_rowid and use for both sets of partitions.

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.

Fixed issues with concurrent DML during REORGANIZE PARTITION for non-clustered tables that had been EXCHANGED.

@ti-chi-bot ti-chi-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. 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. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR. labels Apr 15, 2025
@ti-chi-bot
Copy link
Member Author

@mjonss This PR has conflicts, I have hold it.
Please resolve them or ask others to resolve them, then comment /unhold to remove the hold label.

@ti-chi-bot ti-chi-bot force-pushed the cherry-pick-60132-to-release-8.5 branch from e7c707f to 675cb04 Compare April 15, 2025 04:24
Copy link

codecov bot commented Apr 15, 2025

Codecov Report

Attention: Patch coverage is 83.87097% with 40 lines in your changes missing coverage. Please review.

Please upload report for BASE (release-8.5@d16eb94). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-8.5     #60565   +/-   ##
================================================
  Coverage               ?   58.0663%           
================================================
  Files                  ?       1770           
  Lines                  ?     633214           
  Branches               ?          0           
================================================
  Hits                   ?     367684           
  Misses                 ?     240978           
  Partials               ?      24552           
Flag Coverage Δ
integration 38.5843% <37.5000%> (?)
unit 73.2052% <83.0645%> (?)

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

Components Coverage Δ
dumpling 52.8711% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 63.3717% <0.0000%> (?)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mjonss
Copy link
Contributor

mjonss commented Apr 15, 2025

/retest

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Apr 15, 2025
@mjonss mjonss requested a review from tangenta April 15, 2025 10:15
Copy link

ti-chi-bot bot commented Apr 15, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mjonss, tangenta

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 Apr 15, 2025
Copy link

ti-chi-bot bot commented Apr 15, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-04-15 10:14:54.426608468 +0000 UTC m=+2769788.110844565: ☑️ agreed by mjonss.
  • 2025-04-15 11:39:02.019361035 +0000 UTC m=+2774835.703597126: ☑️ agreed by tangenta.

@mjonss
Copy link
Contributor

mjonss commented Apr 23, 2025

/retest

@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 Apr 23, 2025
@ti-chi-bot ti-chi-bot bot merged commit b2c5f41 into pingcap:release-8.5 Apr 23, 2025
20 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 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. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants