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

store/tikv: wait task channel in Close #2925

Merged
merged 2 commits into from
Mar 27, 2017
Merged

Conversation

coocood
Copy link
Member

@coocood coocood commented Mar 25, 2017

Makes test more stable.

Close distsql result and partial result in executor.

Makes test more stable.

Close distsql result and partial result in executor.
@ngaut ngaut changed the title store/tivk: wait task channel in Close store/tikv: wait task channel in Close Mar 26, 2017
@@ -888,6 +891,7 @@ func (e *XSelectTableExec) Next() (*Row, error) {
}
if rowData == nil {
// Finish the current partial result and get the next one.
e.partialResult.Close()
Copy link
Member

Choose a reason for hiding this comment

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

This will fix memory leak?

Copy link
Member Author

Choose a reason for hiding this comment

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

The partial result should be closed, may fix the potential memory leak.

Copy link
Member Author

Choose a reason for hiding this comment

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

But in this case, the result has been consumed already, there should not have memory leak.

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. partialResult.Close() is a null operation, in distsql/distsql.go
// Close closes the sub result.
func (pr *partialResult) Close() error {
	return nil
}
  1. I'm afraid Close is called many times.

@shenli
Copy link
Member

shenli commented Mar 27, 2017

LGTM

@@ -488,6 +488,7 @@ func (it *copIterator) handleRegionErrorTask(bo *Backoffer, task *copTask) []cop

func (it *copIterator) Close() error {
close(it.finished)
it.wg.Wait()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why need wait here? It's already used in run() function.

Copy link
Member Author

Choose a reason for hiding this comment

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

To make sure the worker goroutines have exited.

defer func() {
close(ch)
close(workCh)
idxResult.Close()
Copy link
Contributor

Choose a reason for hiding this comment

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

move it to executeTask and write like this?

	tblResult, err := e.doTableRequest(task.handles)
	if err != nil {
		return errors.Trace(err)
	}
    defer tblResult.Close()

Copy link
Member Author

Choose a reason for hiding this comment

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

It's index result, not table result.

@tiancaiamao
Copy link
Contributor

LGTM

@coocood coocood merged commit 9f23ab7 into master Mar 27, 2017
@coocood coocood deleted the coocood/make-test-stable branch March 27, 2017 04:28
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.

3 participants