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: break innerTable fetcher is error happend during fetching outer table #7554

Merged
merged 4 commits into from
Aug 30, 2018

Conversation

XuHuaiyu
Copy link
Contributor

What problem does this PR solve?

Break fetchInnerAndBuildHashTable if error happened during fetchOuterAndProbeHashTable.

What is changed and how it works?

Before this PR, if any error happens during fetchOuterAndProbeHashTable,
fetchInnerAndBuildHashTable will continue running, this will cause some
unexpected situations such as DataRace which would may by closing HashJoinExec
while fetchOuterAndProbeHashTable is still running.

This PR checks HashJoinExec.finished evecy time in the loop of
fetchInnerAndBuildHashTable to exists in time if any error happens.

Check List

Tests

  • No code

Code changes

  • Has exported function/method change

Side effects

Related changes

  • Need to cherry-pick to the release branch

@XuHuaiyu XuHuaiyu added type/bugfix This PR fixes a bug. sig/execution SIG execution labels Aug 30, 2018
executor/join.go Outdated
chk := e.innerResult.GetChunk(i)
for j := 0; j < chk.NumRows(); j++ {
if e.finished.Load().(bool) {
Copy link
Member

@zz-jason zz-jason Aug 30, 2018

Choose a reason for hiding this comment

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

This check may slow down the hash table building performance.

Copy link
Member

Choose a reason for hiding this comment

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

maybe we only need to check e.finished in the granularity of Chunk?

@@ -264,6 +264,9 @@ func (e *HashJoinExec) fetchInnerRows(ctx context.Context) (err error) {
e.innerResult.GetMemTracker().AttachTo(e.memTracker)
e.innerResult.GetMemTracker().SetLabel("innerResult")
for {
if e.finished.Load().(bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If the outer table error happened after this and before Next, there is still race.

Copy link
Member

Choose a reason for hiding this comment

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

we need a wait group or mutex to block the close operation on child until this goroutine finishes.

@@ -533,6 +536,9 @@ func (e *HashJoinExec) buildHashTableForList() error {
valBuf = make([]byte, 8)
)
for i := 0; i < e.innerResult.NumChunks(); i++ {
if e.finished.Load().(bool) {
Copy link
Member

Choose a reason for hiding this comment

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

this check can be removed, because we only need to guarantee not calling the next function of the child.

Copy link
Contributor

@alivxxx alivxxx left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

@XuHuaiyu
Copy link
Contributor Author

/run-all-tests

@XuHuaiyu XuHuaiyu merged commit 5823fb5 into pingcap:master Aug 30, 2018
@XuHuaiyu XuHuaiyu deleted the hashjoin branch August 30, 2018 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants