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 a bug when join exists in subquery. #2106

Merged
merged 6 commits into from Nov 30, 2016
Merged

Conversation

hanfei1991
Copy link
Member

When a join exitsts in subquery, the Close will be called before all rows are processed. In this case, we must ensure all channels have been closed.
fix #2009
@shenli @coocood @zimulala @winoros @tiancaiamao @XuHuaiyu PTAL

@@ -484,6 +486,9 @@ type hashJoinCtx struct {

// Close implements the Executor Close interface.
func (e *HashJoinExec) Close() error {
e.finished = true
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you mean

e.closeMu.Lock()
e.finished = true
e.closeMu.Unlock()

Copy link
Member Author

Choose a reason for hiding this comment

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

No, The e.finished should be put front to notify the goroutines to stop

Copy link
Contributor

Choose a reason for hiding this comment

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

so what's the following two line for?

Copy link
Member Author

Choose a reason for hiding this comment

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

add Lock for waiting waitJoinWorkersAndCloseResultChan unlock

Copy link
Contributor

Choose a reason for hiding this comment

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

I think using a channel to notify is better. @hanfei1991 @tiancaiamao

Copy link
Member Author

Choose a reason for hiding this comment

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

How to use a channel to implement it ? @zimulala

@hanfei1991
Copy link
Member Author

@tiancaiamao @zimulala PTAL

e.finished.Store(true)
select {
case _ = <-e.closeLock:
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't need to select and use <-e.closeLock directly.

wg sync.WaitGroup
// closeMu add a lock for closing executor.
closeLock chan bool
Copy link
Contributor

Choose a reason for hiding this comment

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

Using struct {} type is better.

@zimulala
Copy link
Contributor

LGTM

@coocood
Copy link
Member

coocood commented Nov 29, 2016

LGTM

@zimulala zimulala merged commit 9311ce6 into master Nov 30, 2016
@zimulala zimulala deleted the hanfei/wait-group branch November 30, 2016 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Got panic when do the following query
4 participants