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

queuelistener: fix testListener goroutine leak #2506

Merged
merged 1 commit into from
Aug 8, 2023

Conversation

AlexanderYastrebov
Copy link
Member

Queuelistener continously calls Accept on the testListener which keeps a buffer of last accepted testConnections in the conns channel.

The test code races to receive from the same channel so Accept goroutine may occasionally block receiving from the empty channel which would be detected by goroutine leak detector introduced by the #2499.

The problem could be reproduced e.g. by running:

GODEBUG=tracebackancestors=10 go test ./queuelistener/ -run=TestTeardown/connections_accepted_from_the_wrapped_listener_closed_after_tear_down -count=1000

noleak: 1 active

goroutine 2655 [chan receive]:
github.com/zalando/skipper/queuelistener.(*testListener).Accept(0xc0000e7830)
...

This change avoids blocking Accept on potentially empty channel.

Queuelistener continously calls Accept on the testListener which keeps
a buffer of last accepted testConnections in the conns channel.

The test code races to receive from the same channel so Accept goroutine
may occasionally block receiving from the empty channel which would be
detected by goroutine leak detector introduced by the #2499.

The problem could be reproduced e.g. by running:
```
GODEBUG=tracebackancestors=10 go test ./queuelistener/ -run=TestTeardown/connections_accepted_from_the_wrapped_listener_closed_after_tear_down -count=1000

noleak: 1 active

goroutine 2655 [chan receive]:
github.com/zalando/skipper/queuelistener.(*testListener).Accept(0xc0000e7830)
...
```

This change avoids blocking Accept on potentially empty channel.

Signed-off-by: Alexander Yastrebov <[email protected]>
@AlexanderYastrebov
Copy link
Member Author

check-race failed due to #2386

@szuecs
Copy link
Member

szuecs commented Aug 8, 2023

👍

1 similar comment
@AlexanderYastrebov
Copy link
Member Author

👍

@AlexanderYastrebov AlexanderYastrebov merged commit fa84c77 into master Aug 8, 2023
6 checks passed
@AlexanderYastrebov AlexanderYastrebov deleted the queuelistener/fix-testlistener branch August 8, 2023 09:09
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.

2 participants