Fix zombie XA connection after deadlock by deferring closeTxConnections#725
Open
dixitdeepak wants to merge 1 commit into
Open
Fix zombie XA connection after deadlock by deferring closeTxConnections#725dixitdeepak wants to merge 1 commit into
dixitdeepak wants to merge 1 commit into
Conversation
closeTxConnections() was called at the top of rollback() and commit(), before ut.rollback()/ut.commit(). When MySQL auto-rolled back an XA branch due to a deadlock (XA_RBDEADLOCK), BTM attempted XA END on the connection during close(), failed silently, and lost track of the XA resource. The connection was then returned to the pool with an unresolved ROLLBACK_ONLY XA branch still open in MySQL. The next thread to acquire that connection received XAER_RMFAIL on XA START. The fix removes the premature closeTxConnections() calls from both methods. clearCurrent() in the finally block already calls closeTxConnections() as a safety net — it now becomes the sole caller, always running after the JTA operation completes and the XA lifecycle (XA END + XA ROLLBACK/COMMIT) has been properly finalized on all enlisted resources. suspend() is unaffected as it intentionally closes connections before suspending.
Contributor
Author
|
Previously, transaction connections could be closed before UserTransaction.rollback() was executed. This creates a risk that resources participating in the transaction are released before the transaction manager completes rollback processing, particularly in failure scenarios where the resource manager has already reported an error. This change ensures that:
This ordering allows the transaction manager to properly complete rollback processing on all enlisted resources before they are released, reducing the risk of resource state inconsistencies and subsequent transaction enlistment failures when connections are returned to and later reused from the pool. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closeTxConnections()was called at the top ofrollback()andcommit(), before ut.rollback()/ut.commit().When MySQL auto-rolled back an XA branch due to a deadlock (XA_RBDEADLOCK), BTM attempted XA END on the connection during
close(), failed silently, and lost track of the XA resource. The connection was then returned to the pool with an unresolved ROLLBACK_ONLY XA branch still open in MySQL.The next thread to acquire that connection received
XAER_RMFAILon XA START.The fix removes the premature
closeTxConnections()calls from both methods.clearCurrent()in the finally block already callscloseTxConnections()as a safety net — it now becomes the sole caller, always running after the JTA operation completes and the XA lifecycle (XA END + XA ROLLBACK/COMMIT) has been properly finalized on all enlisted resources. suspend() is unaffected as it intentionally closes connections before suspending.