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

Fix #1042 - deadlock in session pool #1065

Merged
merged 5 commits into from
Mar 31, 2024
Merged

Fix #1042 - deadlock in session pool #1065

merged 5 commits into from
Mar 31, 2024

Conversation

mpilquist
Copy link
Member

@mpilquist mpilquist commented Mar 30, 2024

Fixes #1042. Issue occurred when (a) allocated resource failed to be returned to the pool and (b) resource finalizer also failed with an error.

@codecov-commenter
Copy link

codecov-commenter commented Mar 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.94%. Comparing base (1b65f74) to head (b061c52).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1065      +/-   ##
==========================================
+ Coverage   83.91%   83.94%   +0.02%     
==========================================
  Files         138      138              
  Lines        2133     2136       +3     
  Branches      243      243              
==========================================
+ Hits         1790     1793       +3     
  Misses        343      343              

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

@@ -152,7 +152,7 @@ object Pool {
ref.modify {
case (os, Nil) => ((os :+ None, Nil), ().pure[F]) // new empty slot
case (os, d :: ds) => ((os, ds), Concurrent[F].attempt(rsrc(Tracer[F]).allocated).flatMap(d.complete).void) // alloc now!
} .guarantee(a._2).flatten
}.flatten.guarantee(a._2)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upon losing connection to the server, this dispose is called. The deferred removed here (d) should be completed but it's not b/c the finalizer of A completes with the connection error.

@mpilquist mpilquist marked this pull request as ready for review March 30, 2024 17:24
@armanbilge armanbilge self-requested a review March 30, 2024 17:56
@mpilquist mpilquist merged commit bc8e200 into main Mar 31, 2024
21 checks passed
@mpilquist mpilquist deleted the bugfix/1042 branch March 31, 2024 13:24
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 while using session pool
2 participants