Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#46156
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
zimulala authored and ti-chi-bot committed Aug 16, 2023
1 parent 1d77dfd commit ab7b72f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions ddl/split_region.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ func splitPartitionTableRegion(ctx sessionctx.Context, store kv.SplittableStore,
regionIDs = append(regionIDs, preSplitPhysicalTableByShardRowID(ctxWithTimeout, store, tbInfo, def.ID, scatter)...)
}
} else {
<<<<<<< HEAD
for _, def := range pi.Definitions {
regionIDs = append(regionIDs, SplitRecordRegion(ctxWithTimeout, store, def.ID, scatter))
=======
for _, def := range parts {
regionIDs = append(regionIDs, SplitRecordRegion(ctxWithTimeout, store, def.ID, tbInfo.ID, scatter))
>>>>>>> 4fc7970f216 (ddl, session: using table ID instead of partition ID when calling `SplitRegions` (#46156))
}
}
if scatter {
Expand All @@ -58,7 +63,7 @@ func splitTableRegion(ctx sessionctx.Context, store kv.SplittableStore, tbInfo *
if shardingBits(tbInfo) > 0 && tbInfo.PreSplitRegions > 0 {
regionIDs = preSplitPhysicalTableByShardRowID(ctxWithTimeout, store, tbInfo, tbInfo.ID, scatter)
} else {
regionIDs = append(regionIDs, SplitRecordRegion(ctxWithTimeout, store, tbInfo.ID, scatter))
regionIDs = append(regionIDs, SplitRecordRegion(ctxWithTimeout, store, tbInfo.ID, tbInfo.ID, scatter))
}
if scatter {
WaitScatterRegionFinish(ctxWithTimeout, store, regionIDs...)
Expand Down Expand Up @@ -118,8 +123,8 @@ func preSplitPhysicalTableByShardRowID(ctx context.Context, store kv.SplittableS
}

// SplitRecordRegion is to split region in store by table prefix.
func SplitRecordRegion(ctx context.Context, store kv.SplittableStore, tableID int64, scatter bool) uint64 {
tableStartKey := tablecodec.GenTablePrefix(tableID)
func SplitRecordRegion(ctx context.Context, store kv.SplittableStore, physicalTableID, tableID int64, scatter bool) uint64 {
tableStartKey := tablecodec.GenTablePrefix(physicalTableID)
regionIDs, err := store.SplitRegions(ctx, [][]byte{tableStartKey}, scatter, &tableID)
if err != nil {
// It will be automatically split by TiKV later.
Expand Down
2 changes: 1 addition & 1 deletion session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -3100,7 +3100,7 @@ func splitAndScatterTable(store kv.Storage, tableIDs []int64) {
ctxWithTimeout, cancel := context.WithTimeout(context.Background(), variable.DefWaitSplitRegionTimeout*time.Second)
var regionIDs []uint64
for _, id := range tableIDs {
regionIDs = append(regionIDs, ddl.SplitRecordRegion(ctxWithTimeout, s, id, variable.DefTiDBScatterRegion))
regionIDs = append(regionIDs, ddl.SplitRecordRegion(ctxWithTimeout, s, id, id, variable.DefTiDBScatterRegion))
}
if variable.DefTiDBScatterRegion {
ddl.WaitScatterRegionFinish(ctxWithTimeout, s, regionIDs...)
Expand Down

0 comments on commit ab7b72f

Please sign in to comment.