r2dbc / r2dbc-pool

Connection Pooling for Reactive Relational Database Connectivity
https://r2dbc.io
Apache License 2.0
331 stars 55 forks source link

Fix r2dbc connection pool returning multiple pooled objects pointing to same database connection #210

Open Azukovskij opened 3 months ago

Azukovskij commented 3 months ago

R2dbc returns multiple pooled objects pointing to same database connection in case downstream gets disposed, e.g.

Dispose event in downstream causes ref.release().subscribe(); to be invoked that releases pooled references (without calling preDestroy or any kind of logging event). As a result another pending invocation ConnectionPool#create receives same database connection, that has not yet been closed and has not finished processing in initial subscription.

This causes connection sharing issues on higher load that lead to lost cursor and data consistency issues (when transactions are leaked).