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 r2dbc connection pool returning multiple pooled objects pointing to same database connection #210

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Azukovskij
Copy link

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

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.

1 participant