-
Notifications
You must be signed in to change notification settings - Fork 6k
*: Allow Point_Get during DDL with Global Index #56382
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
Merged
ti-chi-bot
merged 18 commits into
pingcap:master
from
mjonss:global-index-point-get-during-ddl
Oct 25, 2024
Merged
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
82ed64a
*: Allow Point_Get during DDL with Global Index
mjonss ace4c13
Added comment
mjonss 25d56a7
Added back check for empty set of partitions after pruning
mjonss e9424d8
reshuffled code
mjonss c4f0a13
Added todo comment
mjonss 3a1271a
Clarified comment
mjonss 20aabb5
Merge remote-tracking branch 'pingcap/master' into global-index-point…
mjonss b7735b4
Merge remote-tracking branch 'pingcap/master' into global-index-point…
mjonss 5d0903e
Added intest assertion
mjonss 3974c7e
Merge remote-tracking branch 'pingcap/master' into global-index-point…
mjonss d4b94fc
Linting
mjonss ba60603
Merge remote-tracking branch 'pingcap/master' into global-index-point…
mjonss c073881
Manual merge fixes
mjonss 0883f7c
Removed duplicated line
mjonss 27dbf70
Merge remote-tracking branch 'pingcap/master' into global-index-point…
mjonss 8597552
Added test for issue 56819.
mjonss 731d794
Removed duplicated lines.
mjonss fdbae50
using intest.Assert instead of intest.InTest.
mjonss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1007,6 +1007,69 @@ func (pi *PartitionInfo) SetOriginalPartitionIDs() { | |
pi.OriginalPartitionIDsOrder = ids | ||
} | ||
|
||
// IDsInDDLToIgnore returns a list of IDs that the current | ||
// session should not see (may be duplicate errors on insert/update though) | ||
// For example during truncate or drop partition. | ||
func (pi *PartitionInfo) IDsInDDLToIgnore() []int64 { | ||
// TODO: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are multiple PRs/enhancements that will build upon this, especially for DROP and TRUNCATE partition. |
||
// Truncate partition: | ||
// write only => should not see NewPartitionIDs | ||
// delete only => should not see DroppingPartitions | ||
// Drop partition: | ||
// TODO: Make similar changes as in Truncate Partition: | ||
// Add a state blocking read and write in the partitions to be dropped, | ||
// to avoid situations like https://github.com/pingcap/tidb/issues/55888 | ||
// Add partition: | ||
// TODO: Add tests! | ||
// Exchange Partition: | ||
// Currently blocked for GlobalIndex | ||
// Reorganize Partition: | ||
// Nothing, since it will create a new copy of the global index. | ||
// This is due to the global index needs to have two partitions for the same index key | ||
// TODO: Should we extend the GlobalIndex to have multiple partitions? | ||
// Maybe from PK/_tidb_rowid + Partition ID | ||
// to PK/_tidb_rowid + Partition ID + Valid from Schema Version, | ||
// with support for two entries? | ||
// Then we could avoid having two copies of the same Global Index | ||
// just for handling a single SchemaState. | ||
// If so, could we then replace this? | ||
switch pi.DDLAction { | ||
case ActionTruncateTablePartition: | ||
switch pi.DDLState { | ||
case StateWriteOnly: | ||
return pi.NewPartitionIDs | ||
case StateDeleteOnly, StateDeleteReorganization: | ||
if len(pi.DroppingDefinitions) == 0 { | ||
return nil | ||
} | ||
ids := make([]int64, 0, len(pi.DroppingDefinitions)) | ||
for _, definition := range pi.DroppingDefinitions { | ||
ids = append(ids, definition.ID) | ||
} | ||
return ids | ||
} | ||
case ActionDropTablePartition: | ||
if len(pi.DroppingDefinitions) > 0 && pi.DDLState == StateDeleteOnly { | ||
ids := make([]int64, 0, len(pi.DroppingDefinitions)) | ||
for _, def := range pi.DroppingDefinitions { | ||
ids = append(ids, def.ID) | ||
} | ||
return ids | ||
} | ||
case ActionAddTablePartition: | ||
// TODO: Add tests for ADD PARTITION multi-domain with Global Index! | ||
if len(pi.AddingDefinitions) > 0 { | ||
ids := make([]int64, 0, len(pi.DroppingDefinitions)) | ||
for _, def := range pi.AddingDefinitions { | ||
ids = append(ids, def.ID) | ||
} | ||
return ids | ||
} | ||
// Not supporting Global Indexes: case ActionExchangeTablePartition | ||
} | ||
return nil | ||
} | ||
|
||
// PartitionState is the state of the partition. | ||
type PartitionState struct { | ||
ID int64 `json:"id"` | ||
|
@@ -1023,7 +1086,7 @@ type PartitionDefinition struct { | |
Comment string `json:"comment,omitempty"` | ||
} | ||
|
||
// Clone clones ConstraintInfo. | ||
// Clone clones PartitionDefinition. | ||
func (ci *PartitionDefinition) Clone() PartitionDefinition { | ||
nci := *ci | ||
nci.LessThan = make([]string, len(ci.LessThan)) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.