Skip to content

Retain R2DBC connections until transaction cleanup - #37373

Open
Emin0v wants to merge 1 commit into
spring-projects:mainfrom
Emin0v:fix/r2dbc-synchronized-holder-release-leak
Open

Emin0v wants to merge 1 commit into
spring-projects:mainfrom
Emin0v:fix/r2dbc-synchronized-holder-release-leak

Conversation

@Emin0v

@Emin0v Emin0v commented Oct 1, 2026

Copy link
Copy Markdown

This fixes the connection leak reported in #37359.

When a connection is explicitly released inside a reactive transaction, ConnectionHolder.released() clears currentConnection once the reference count reaches zero. The transaction synchronization then has no connection left to close during cleanup.

The change keeps the connection in the holder while it is synchronized with a transaction. The release behavior for other holders remains unchanged.

I added two regression tests covering connection reuse within the same transaction and release before transaction suspension. Both tests fail on the original code and pass with this fix.

The spring-r2dbc tests and Checkstyle checks pass.

Closes gh-37359

Closes spring-projectsgh-37359

Signed-off-by: Mahammad Eminov <64434582+Emin0v@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 1, 2026 11:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 1, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spring-r2dbc: Connection is not closed after explicit release in a reactive transaction

3 participants