Skip to content
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

executor: fix data race on the IndexMergeReaderExecutor #39513

Merged
merged 5 commits into from
Dec 1, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions executor/index_merge_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ var (
type IndexMergeReaderExecutor struct {
baseExecutor

table table.Table
indexes []*model.IndexInfo
descs []bool
ranges [][]*ranger.Range
dagPBs []*tipb.DAGRequest
startTS uint64
tableRequest *tipb.DAGRequest
table table.Table
indexes []*model.IndexInfo
descs []bool
ranges [][]*ranger.Range
dagPBs []*tipb.DAGRequest
startTS uint64
tableRequestMu sync.Mutex
tableRequest *tipb.DAGRequest
// columns are only required by union scan.
columns []*model.ColumnInfo
*dataReaderBuilder
Expand Down Expand Up @@ -631,7 +632,13 @@ func (e *IndexMergeReaderExecutor) buildFinalTableReader(ctx context.Context, tb
netDataSize: e.dataAvgRowSize * float64(len(handles)),
}
if e.isCorColInTableFilter {
if tableReaderExec.dagPB.Executors, err = constructDistExec(e.ctx, e.tblPlans); err != nil {
err = func() error {
e.tableRequestMu.Lock()
defer e.tableRequestMu.Unlock()
tableReaderExec.dagPB.Executors, err = constructDistExec(e.ctx, e.tblPlans)
Copy link
Collaborator

@guo-shaoge guo-shaoge Dec 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can construct DistExec in IndexMergeExec.Open(), so no need to use lock?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return err
}()
if err != nil {
return nil, err
}
}
Expand Down