-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Conversation
Makes test more stable. Close distsql result and partial result in executor.
@@ -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() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- partialResult.Close() is a null operation, in distsql/distsql.go
// Close closes the sub result.
func (pr *partialResult) Close() error {
return nil
}
- I'm afraid Close is called many times.
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() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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()
There was a problem hiding this comment.
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.
LGTM |
Makes test more stable.
Close distsql result and partial result in executor.