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

server: fix deadlock when closing concurrently with transport #4332

Merged
merged 2 commits into from Mar 3, 2024

Conversation

sukunrt
Copy link
Collaborator

@sukunrt sukunrt commented Feb 17, 2024

When the listener and transport are closed concurrently. We can get a deadlock

Listener.Close is in Listener.CloseOnce.Do block and calls transport.closeServer for notifyOnClose. transport.closeServer requires Transport.mutex

Transport.Close holds the Transport.mutex and calls Listener.Close and gets stuck at the Listener.closeOnce.Do block

Copy link

codecov bot commented Feb 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.27%. Comparing base (c786a46) to head (121b82c).
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4332      +/-   ##
==========================================
+ Coverage   84.80%   85.27%   +0.47%     
==========================================
  Files         150      150              
  Lines       14251    14466     +215     
==========================================
+ Hits        12085    12335     +250     
+ Misses       1668     1644      -24     
+ Partials      498      487      -11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@marten-seemann
Copy link
Member

Does this PR target #4266?

@sukunrt
Copy link
Collaborator Author

sukunrt commented Feb 17, 2024

Oh sorry. Yes. I didnt realise there was an open PR. Happy to close this.

@marten-seemann
Copy link
Member

#4266 is the issue, not a PR. Please keep this one open.

@marten-seemann marten-seemann linked an issue Feb 17, 2024 that may be closed by this pull request
@marten-seemann
Copy link
Member

@sukunrt Did you have a way to reliably trigger this deadlock? If so, would it make sense to add this as a test case here?

@sukunrt
Copy link
Collaborator Author

sukunrt commented Mar 3, 2024

On my machine this test is consistently deadlocking on master.

@marten-seemann
Copy link
Member

Thank you @sukunrt!

@marten-seemann marten-seemann merged commit d6269b7 into master Mar 3, 2024
34 checks passed
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.

deadlock when closing transport and/or server
2 participants