Skip to content

[5.28] Fix race condition in bolt connection pool - #1348

Merged
robsdedude merged 4 commits into
neo4j:5.0from
robsdedude:fix/bolt-pool-race-condition-5.28
Sep 24, 2026
Merged

robsdedude merged 4 commits into
neo4j:5.0from
robsdedude:fix/bolt-pool-race-condition-5.28

Conversation

@robsdedude

Copy link
Copy Markdown
Member

Backport of: #1346

Closes: DRIVERS-578

The pool tries to acquire an idle connection first. If no idle connection is
available, it puts itself into a queue waiting for another thread/task to return
a connection before trying again.

However, there is no protection against a connection being returned between the
attempt to acquire an idle connection and the enqueuing. Therefore, it could
happen that a thread waits indefinitely like this:

Assume max pool size of 1

 * T1 creates & acquires con1
 * T2 checks for idle connections => None
 * T1 releases con1
 * T2 acquires lock to be able to wait for the release event
 * T1 terminates
 * T2 times out waiting for Godot
@robsdedude
robsdedude marked this pull request as ready for review September 23, 2026 21:06

@StephenCathcart StephenCathcart left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💯

@robsdedude
robsdedude merged commit 4a00ff5 into neo4j:5.0 Sep 24, 2026
27 checks passed
@robsdedude
robsdedude deleted the fix/bolt-pool-race-condition-5.28 branch September 24, 2026 13:30
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