Skip to content

Commit

Permalink
ddl, session: using table ID instead of partition ID when calling `Sp…
Browse files Browse the repository at this point in the history
…litRegions` (#46156) (#46161)

close #46135
  • Loading branch information
ti-chi-bot authored Oct 8, 2023
1 parent 0155485 commit 753fb3d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions ddl/split_region.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func splitPartitionTableRegion(ctx sessionctx.Context, store kv.SplittableStore,
}
} else {
for _, def := range pi.Definitions {
regionIDs = append(regionIDs, SplitRecordRegion(ctxWithTimeout, store, def.ID, scatter))
regionIDs = append(regionIDs, SplitRecordRegion(ctxWithTimeout, store, def.ID, tbInfo.ID, scatter))
}
}
if scatter {
Expand All @@ -58,7 +58,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 +118,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 @@ -3111,7 +3111,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 753fb3d

Please sign in to comment.