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 Transaction already completed issue #29065

Closed

Conversation

Vladislav-Zolotaryov
Copy link

I have encountered an issue when using Reactive Transactions with PostgreSQL in Serialized Isolation mode, that when commit fails with ConcurrencyFailureException, TransactionalOperator actually tries to call rollback on the transaction.

The issue is that in ReactiveTransactionManager#rollback method, it is stated in case if commit threw an exception - you should not call the rollback method.

Currently when ReactiveTransactionManager#commit fails, the TransactionalOperator actually calls the rollbackOnException and it causes the rollback method to throw IllegalTransactionStateException with message about the transaction already being complete.

My proposal to fix this, is to wrap and exceptions that rise from commit phase in Flux/Mono.whenUsing into a special TransactionCommitException that allows us the decide weather to rollback or no, and also propagate it upstream so that client could decide to retry on such an occasion.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Sep 2, 2022
@pivotal-cla
Copy link

@Vladislav-Zolotaryov Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-cla
Copy link

@Vladislav-Zolotaryov Thank you for signing the Contributor License Agreement!

@poutsma poutsma added the in: data Issues in data modules (jdbc, orm, oxm, tx) label Jan 30, 2023
@snicoll
Copy link
Member

snicoll commented Aug 27, 2023

@mp911de can you please look at this one when you get a chance? Thanks!

@Vladislav-Zolotaryov
Copy link
Author

Vladislav-Zolotaryov commented Aug 28, 2023

It seems that since I reported it almost a year ago, @EnricSala fixed this issue by unwrapping the exception produced by Flux#usingWhen in TransactionalOperatorImpl#unwrapIfResourceCleanupFailure

So even in case when commit fails with something like ConcurrencyFailureException, we should be able to properly write retry logic

Closing the issue, thank you @EnricSala

@sbrannen
Copy link
Member

@sbrannen sbrannen added status: superseded An issue that has been superseded by another and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: superseded An issue that has been superseded by another
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants