Uh oh!
There was an error while loading. Please reload this page.
Fix leak of watchMiss goroutine - #1786
Conversation
fcrisciani
commented
May 30, 2017
Stacktrace related in 17.03: |
| for { | ||
| msgs, err := nlSock.Receive() | ||
| if err != nil { | ||
| if nlSock.GetFd() == -1 { |
There was a problem hiding this comment.
This needs locking to avoid a data race involving nlSock.fd.
| // Close the netlink socket, this will also release the watchMiss goroutine that is using it | ||
| if n.nlSocket != nil { | ||
| n.nlSocket.Close() |
There was a problem hiding this comment.
This needs locking to avoid a data race involving nlSock.fd. Close could race with Receive or GetFd.
There was a problem hiding this comment.
network lock is already taken before calling the destroySandbox, this looks like is by design, see the comment on top of the function: https://github.com/docker/libnetwork/blob/master/drivers/overlay/ov_network.go#L267
fcrisciani
commented
May 31, 2017
@aaronlehmann can you give another round of review? as this LG for you I will update the backport |
aaronlehmann
commented
May 31, 2017
|
fcrisciani
commented
May 31, 2017
goroutine A is blocked on the Receive on the netlink socket Do you have in mind some other scenario? In this case the lock is the network one that guarantees the safety of the netlink socket. |
aaronlehmann
commented
May 31, 2017
goroutine A calls Receive, which checks if s.fd < 0. At this time, s.fd >= 0. This is really a bug in |
fcrisciani
commented
May 31, 2017
In this case it is still fine, because you want to avoid the race between the Close and the GetFD (Receive a part from the initial check on the fd will return what the syscall returns so no issue there) and that is done using the network mutex. In general the linux socket are not thread safe, but sure a more clean way would be to protect the fd with the mutex that is inside the netlink library |
aaronlehmann
commented
Jun 1, 2017
I opened vishvananda/netlink#234 upstream |
fcrisciani
commented
Jun 1, 2017
will wait for it to be merged and update this commit then |
The netlink socket that was used to monitor the L2 miss was never being closed. The watchMiss goroutine spawned was never returning. This was causing goroutine leak in case of createNetwork/destroyNetwork Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
mavenugo
commented
Jun 6, 2017
Thanks @fcrisciani and @aaronlehmann LGTM |
ityangchen
commented
Nov 16, 2017
when repeated operate |
fcrisciani
commented
Nov 16, 2017
@ityangchen this is the follow up PR |
The netlink socket that was used to monitor the L2
miss was never being closed. The watchMiss goroutine
spawned was never returning. This was causing goroutine
leak in case of createNetwork/destroyNetwork
Signed-off-by: Flavio Crisciani flavio.crisciani@docker.com