r2dbc-pool icon indicating copy to clipboard operation
r2dbc-pool copied to clipboard

R2dbc connection pool returns multiple pooled objects pointing to same database connection

Open Azukovskij opened this issue 1 year ago • 5 comments

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

  • Downstream Mono converted from Flux or other Publisher (e.g. any RxJava type)
  • Dispose called from different thread, e.g. Flux.onError, Mono.onError invoked from timeout operator on different scheduler
  • Number of results is limited via Flux.take

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).

Please see https://github.com/r2dbc/r2dbc-pool/pull/210 for unit test reproducing the issue and proposed solution - in case more full-proof solution is required connection dispose hook can be added on PooledConnection via Cleaner

Azukovskij avatar May 14 '24 15:05 Azukovskij

this looks like a really nasty bug and no attention from maintainers since May? 🤯

62mkv avatar Dec 30 '24 09:12 62mkv

is it possible to ask @mp911de to comment on this, is it considered an issue, critical/non-critical, any plans about it? Thanks a lot in advance 🙏

62mkv avatar Jan 20 '25 13:01 62mkv

The overall issue is that Broadcom has almost halved our team who was looking into R2DBC. We have no capacity to look into projects other than our core duties. This is a really depressing situation for me as I spent a lot of time on R2DBC to bring it into a proper state. It is painful to see how things fall apart and that I cannot spend time here.

That being said, any help from the community is greatly appreciated, especially since these topics aren't simple. It requires a lot of time to mentally get into the problems and analyze what is going on before a fix can be made.

mp911de avatar Jan 20 '25 14:01 mp911de

Thanks Mark! Really sad that this is the reality... Stay strong! 🙏🙏

62mkv avatar Jan 20 '25 15:01 62mkv

Any chances having this fixed ? :(

kvaster avatar Sep 14 '25 20:09 kvaster