-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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: call Next() after copIterator closed lead to goroutine leak #5624
Conversation
Could you add a test case to cover this? |
/run-all-tests |
I'll try it tomorrow, anyway, github is down right now. |
It seems not so easy to reproduce. @shenli
|
/run-all-tests -tidb-test=release-1.0 -private-test=release-1.0 |
/run-all-tests tidb-test=release-1.0 tikv=release-1.0 tidb-private-test=release-1.0 |
/run-all-tests tidb-test=pr/441 tidb-private-test=pr/4 tikv=release-1.0 |
Have you tried gofail? |
/run-all-tests tidb-test=release-1.0 tikv=release-1.0 tidb-private-test=release-1.0 |
After Close(), worker groutine receive from copIterator.finished and exit directly, without writing any thing to taskCh. Next() receives from taskCh and may hang forever, cause the caller goroutine leak.
9e543d9
to
17c3e3d
Compare
/run-all-tests tidb-test=release-1.0 tikv=release-1.0 tidb-private-test=release-1.0 |
for { | ||
if it.curr >= len(it.tasks) { | ||
// Resp will be nil if iterator is finished. | ||
return nil, nil | ||
} | ||
task := it.tasks[it.curr] | ||
resp, ok = <-task.respChan | ||
resp, ok, closed = recvFromRespCh(task.respChan, it.finished) |
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 not just close the task.respChan in copIterator.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.
Because send to a closed channel would panic.
for { | ||
if it.curr >= len(it.tasks) { | ||
// Resp will be nil if iterator is finished. | ||
return nil, nil | ||
} | ||
task := it.tasks[it.curr] | ||
resp, ok = <-task.respChan | ||
resp, ok, closed = recvFromRespCh(task.respChan, it.finished) |
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.
s/closed/exit/ or s/exit/closed/
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.
I think closed is better, you see the comment line in the next line:
// Close() is already called, so Next() is invalid.
LGTM |
1 similar comment
LGTM |
…ak (pingcap#5624) After Close(), worker groutine receive from copIterator.finished and exit directly, without writing any thing to taskCh. Next() receives from taskCh and may hang forever, cause the caller goroutine leak.
After Close(), worker groutine receive signal from copIterator.finished and
exit directly, without writing any thing to taskCh.
Next() receives from taskCh and may hang forever, cause the caller goroutine
leak.
@shenli @coocood