Skip to content

Commit

Permalink
ddl: add error check in ddlCtx.buildDescTableScan (pingcap#8726)
Browse files Browse the repository at this point in the history
  • Loading branch information
winkyao authored Dec 18, 2018
1 parent 198971f commit 4899ce5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ddl/reorg.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ func (d *ddlCtx) buildDescTableScan(ctx context.Context, startTS uint64, tbl tab
builder.Request.Priority = kv.PriorityLow

kvReq, err := builder.Build()
if err != nil {
return nil, errors.Trace(err)
}

sctx := newContext(d.store)
result, err := distsql.Select(ctx, sctx, kvReq, getColumnsTypes(columns), statistics.NewQueryFeedback(0, nil, 0, false))
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions executor/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ func (e *CheckIndexRangeExec) Open(ctx context.Context) error {
SetKeepOrder(true).
SetFromSessionVars(e.ctx.GetSessionVars()).
Build()
if err != nil {
return errors.Trace(err)
}

e.result, err = distsql.Select(ctx, e.ctx, kvReq, e.retFieldTypes, statistics.NewQueryFeedback(0, nil, 0, false))
if err != nil {
Expand Down Expand Up @@ -259,6 +262,9 @@ func (e *RecoverIndexExec) buildTableScan(ctx context.Context, txn kv.Transactio
SetKeepOrder(true).
SetFromSessionVars(e.ctx.GetSessionVars()).
Build()
if err != nil {
return nil, errors.Trace(err)
}

// Actually, with limitCnt, the match datas maybe only in one region, so let the concurrency to be 1,
// avoid unnecessary region scan.
Expand Down Expand Up @@ -621,6 +627,10 @@ func (e *CleanupIndexExec) buildIndexScan(ctx context.Context, txn kv.Transactio
SetKeepOrder(true).
SetFromSessionVars(e.ctx.GetSessionVars()).
Build()
if err != nil {
return nil, errors.Trace(err)
}

kvReq.KeyRanges[0].StartKey = kv.Key(e.lastIdxKey).PrefixNext()
kvReq.Concurrency = 1
result, err := distsql.Select(ctx, e.ctx, kvReq, e.getIdxColTypes(), statistics.NewQueryFeedback(0, nil, 0, false))
Expand Down
3 changes: 3 additions & 0 deletions executor/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ func (e *AnalyzeIndexExec) open() error {
SetKeepOrder(true).
SetConcurrency(e.concurrency).
Build()
if err != nil {
return errors.Trace(err)
}
ctx := context.TODO()
e.result, err = distsql.Analyze(ctx, e.ctx.GetClient(), kvReq, e.ctx.GetSessionVars().KVVars, e.ctx.GetSessionVars().InRestrictedSQL)
if err != nil {
Expand Down

0 comments on commit 4899ce5

Please sign in to comment.