-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
base: master
Are you sure you want to change the base?
Conversation
Hi @mjonss. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with 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. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #55831 +/- ##
=================================================
- Coverage 73.2077% 57.0900% -16.1177%
=================================================
Files 1652 1803 +151
Lines 456113 642928 +186815
=================================================
+ Hits 333910 367048 +33138
- Misses 101690 250698 +149008
- Partials 20513 25182 +4669
Flags with carried forward coverage won't be shown. Click here to find out more.
|
/retest |
@mjonss: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
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. |
/retest |
@mjonss: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
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. |
/retest |
@purelind: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for planner part
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: winoros The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
@@ -551,6 +583,32 @@ func FetchDuplicatedHandle(ctx context.Context, key kv.Key, distinct bool, | |||
return true, nil, nil | |||
} | |||
|
|||
// GetPartitionHandleFromVal creates a PartitionHandle from a global index value | |||
func GetPartitionHandleFromVal(val []byte) (*kv.PartitionHandle, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use DecodeHandleInIndexValue
function?
@@ -2277,7 +2248,7 @@ func (w *worker) onDropTablePartition(jobCtx *jobContext, job *model.Job) (ver i | |||
// Since the previous state do not use the dropping partitions, | |||
// we can now actually remove them, allowing to write into the overlapping range | |||
// of the higher range partition or LIST default partition. | |||
physicalTableIDs = updateDroppingPartitionInfo(tblInfo, partNames) | |||
_ = updateDroppingPartitionInfo(tblInfo, partNames) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_ = updateDroppingPartitionInfo(tblInfo, partNames) | |
updateDroppingPartitionInfo(tblInfo, partNames) |
@@ -2266,7 +2237,7 @@ func (w *worker) onDropTablePartition(jobCtx *jobContext, job *model.Job) (ver i | |||
// Reason, see https://github.com/pingcap/tidb/issues/55888 | |||
// Only mark the partitions as to be dropped, so they are not used, but not yet removed. | |||
originalDefs := tblInfo.Partition.Definitions | |||
physicalTableIDs = updateDroppingPartitionInfo(tblInfo, partNames) | |||
_ = updateDroppingPartitionInfo(tblInfo, partNames) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_ = updateDroppingPartitionInfo(tblInfo, partNames) | |
updateDroppingPartitionInfo(tblInfo, partNames) |
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 fromStateDeleteOnly
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 fromStateWriteOnly
(old partition, to be truncated) collides with a newly written entry inStateDeleteOnly
(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
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.