Skip to content

server: fix deadlock when closing concurrently with transport#4332

Merged
marten-seemann merged 2 commits intomasterfrom
server-transport-deadlock
Mar 3, 2024
Merged

server: fix deadlock when closing concurrently with transport#4332
marten-seemann merged 2 commits intomasterfrom
server-transport-deadlock

Conversation

@sukunrt
Copy link
Copy Markdown
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

@codecov
Copy link
Copy Markdown

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
Copy Markdown
Member

Does this PR target #4266?

@sukunrt
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator Author

sukunrt commented Mar 3, 2024

On my machine this test is consistently deadlocking on master.

@marten-seemann
Copy link
Copy Markdown
Member

Thank you @sukunrt!

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