Skip to content

Commit

Permalink
handle table scan when reorg
Browse files Browse the repository at this point in the history
Signed-off-by: you06 <you1474600@gmail.com>
  • Loading branch information
you06 committed Feb 14, 2023
1 parent cc40bf1 commit 79d2945
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion ddl/backfilling.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ type reorgBackfillTask struct {
startKey kv.Key
endKey kv.Key
endInclude bool
source string
}

func (r *reorgBackfillTask) excludedEndKey() kv.Key {
Expand Down Expand Up @@ -498,6 +499,7 @@ func (dc *ddlCtx) handleRangeTasks(scheduler *backfillScheduler, t table.Table,
}
// Build reorg tasks.
job := reorgInfo.Job
source := getDDLRequestSource(job)
for i, keyRange := range kvRanges {
endKey := keyRange.EndKey
endK, err := getRangeEndKey(scheduler.jobCtx, dc.store, job.Priority, prefix, keyRange.StartKey, endKey)
Expand All @@ -515,7 +517,9 @@ func (dc *ddlCtx) handleRangeTasks(scheduler *backfillScheduler, t table.Table,
startKey: keyRange.StartKey,
endKey: endKey,
// If the boundaries overlap, we should ignore the preceding endKey.
endInclude: endK.Cmp(keyRange.EndKey) != 0 || i == len(kvRanges)-1}
endInclude: endK.Cmp(keyRange.EndKey) != 0 || i == len(kvRanges)-1,
source: source,
}
batchTasks = append(batchTasks, task)

if len(batchTasks) >= backfillTaskChanSize {
Expand Down
9 changes: 8 additions & 1 deletion ddl/index_cop.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ func (c *copReqSender) run() {
p.resultsCh <- idxRecResult{id: task.id, err: err}
return
}
rs, err := p.copCtx.buildTableScan(p.ctx, ver.Ver, task.startKey, task.excludedEndKey())
ctx := kv.WithInternalSourceType(p.ctx, task.source)
rs, err := p.copCtx.buildTableScan(ctx, ver.Ver, task.startKey, task.excludedEndKey())
if err != nil {
p.resultsCh <- idxRecResult{id: task.id, err: err}
return
Expand Down Expand Up @@ -422,6 +423,12 @@ func (c *copContext) buildTableScan(ctx context.Context, startTS uint64, start,
SetFromInfoSchema(c.sessCtx.GetDomainInfoSchema()).
SetConcurrency(1).
Build()
builder.RequestSource.RequestSourceInternal = true
if source := ctx.Value(kv.RequestSourceKey); source != nil {
builder.RequestSource.RequestSourceType = source.(kv.RequestSource).RequestSourceType
} else {
builder.RequestSource.RequestSourceType = kv.InternalTxnDDL
}
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 79d2945

Please sign in to comment.