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

*: Truncate partition with global index improvement #55831

Merged
merged 95 commits into from
Nov 20, 2024

Conversation

mjonss
Copy link
Contributor

@mjonss mjonss commented Sep 3, 2024

What problem does this PR solve?

Issue Number: close #55819

Problem Summary:
During TRUNCATE PARTITION writes was blocked to partitions that was being truncated, also during StateDeleteReorganization, meaning the DDL would block writes to all truncated partitions for the full duration of the DDL, in case of a Global Index.

What changed and how does it work?

Instead of simply blocking writes to partitions being truncated, we are hiding the new partitions from Global Indexes StateWriteOnly and old partitions from StateDeleteOnly so that they cannot be seen, and not cause any anomaly, where you can find data or not depending on access method, i.e. it may be found if using Global Index, but not for table scan.

A side effect of this is that we are still blocking duplicate keys, if a write to a global unique index from a StateDeleteOnly client that collides with a not-yet cleaned up Global Index entry, or a write to a global unique index from StateWriteOnly (old partition, to be truncated) collides with a newly written entry in StateDeleteOnly (using the new emptied partition).

To not generate these kind of duplicate errors for too long period, duplicate key errors are not generated during StateDeleteReorganization if the duplicate comes from an old truncated partition, instead that global unique index entry is overwritten.

Also refactored/deduplicated code for cleaning up the global index entries from dropped/truncated partitions, so both DROP and TRUNCATE PARTITION uses the same code.

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.

Removed write blocking partitions involved in TRUNCATE PARTITIONs if they had a Global Index.

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/invalid-title size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 3, 2024
Copy link

tiprow bot commented Sep 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.

@mjonss mjonss changed the title Truncate partition global index *: Truncate partition with global index improvement Sep 3, 2024
Copy link

codecov bot commented Sep 3, 2024

Codecov Report

Attention: Patch coverage is 75.62189% with 49 lines in your changes missing coverage. Please review.

Project coverage is 75.2357%. Comparing base (50b5cd2) to head (c8f9c4b).
Report is 14 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #55831        +/-   ##
================================================
+ Coverage   72.8328%   75.2357%   +2.4028%     
================================================
  Files          1672       1721        +49     
  Lines        462993     476569     +13576     
================================================
+ Hits         337211     358550     +21339     
+ Misses       104974      95919      -9055     
- Partials      20808      22100      +1292     
Flag Coverage Δ
integration 49.8860% <51.2437%> (?)
unit 72.5967% <75.6218%> (+0.3802%) ⬆️

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

Components Coverage Δ
dumpling 52.7673% <ø> (ø)
parser ∅ <ø> (∅)
br 64.1794% <ø> (+19.0856%) ⬆️
---- 🚨 Try these New Features:

pkg/ddl/partition.go Outdated Show resolved Hide resolved
pkg/ddl/partition.go Show resolved Hide resolved
Copy link
Contributor

@Defined2014 Defined2014 left a comment

Choose a reason for hiding this comment

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

LGTM, please move some lines back into StateDeleteReorganization

pkg/ddl/partition.go Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Nov 12, 2024
Copy link

ti-chi-bot bot commented Nov 12, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-11-01 16:13:06.31262172 +0000 UTC m=+625499.151777263: ☑️ agreed by winoros.
  • 2024-11-12 04:17:59.595394691 +0000 UTC m=+329841.786263688: ☑️ agreed by Defined2014.

Copy link

tiprow bot commented Nov 12, 2024

@mjonss: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
fast_test_tiprow 5b14000 link true /test fast_test_tiprow

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@mjonss
Copy link
Contributor Author

mjonss commented Nov 20, 2024

/retest

Copy link

tiprow bot commented Nov 20, 2024

@mjonss: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

Copy link

ti-chi-bot bot commented Nov 20, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Defined2014, tangenta, winoros

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 the approved label Nov 20, 2024
@mjonss
Copy link
Contributor Author

mjonss commented Nov 20, 2024

/retest

Copy link

tiprow bot commented Nov 20, 2024

@mjonss: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

@mjonss
Copy link
Contributor Author

mjonss commented Nov 20, 2024

/retest

Copy link

tiprow bot commented Nov 20, 2024

@mjonss: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

@mjonss
Copy link
Contributor Author

mjonss commented Nov 20, 2024

/retest

Copy link

tiprow bot commented Nov 20, 2024

@mjonss: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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 merged commit 865b283 into pingcap:master Nov 20, 2024
25 checks passed
@mjonss mjonss deleted the truncate-partition-global-index branch November 20, 2024 17:02
mjonss added a commit to mjonss/tidb that referenced this pull request Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner 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.

Truncate partition with global index blocks inserts also during delete reorganization state
5 participants