Skip to content

Commit

Permalink
Fix race condition in pool (#610)
Browse files Browse the repository at this point in the history
* Fix race condition in pool

Co-authored-by: Robsdedude <rouven.bauer@neo4j.com>

---------

Co-authored-by: Robsdedude <rouven.bauer@neo4j.com>
  • Loading branch information
StephenCathcart and robsdedude authored Nov 27, 2024
1 parent 2a4727c commit a9c3fc5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions neo4j/internal/pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ func (p *Pool) Return(ctx context.Context, c idb.Connection) {

// Shouldn't return a too old or dead connection back to the pool
if !isAlive || age >= p.config.MaxConnectionLifetime {
// Fix for race condition where expired connections could be reused or closed concurrently.
// See: https://github.com/neo4j/neo4j-go-driver/issues/574
isAlive = false
p.unreg(ctx, serverName, c, now)
p.log.Infof(log.Pool, p.logId, "Unregistering dead or too old connection to %s", serverName)
}
Expand Down

0 comments on commit a9c3fc5

Please sign in to comment.