Skip to content

Conversation

PatrickMNL
Copy link
Contributor

No description provided.

…fterwards to clean up the connection state.

Signed-off-by: Patrick le Duc <[email protected]>
@PatrickMNL
Copy link
Contributor Author

PatrickMNL commented Sep 2, 2025

Unfortunately I have to make adjustments in this method once again (after applying fixes for MariaDB 10.6.12+ here #1317 and for MariaDB 11.8.3+ here #1585).

We have migrated to AWS Aurora MySQL and since then we were suffering from connections that remained in an invalid state after having suffered a deadlock (while using XA). The connection that suffered from the deadlock subsequently kept throwing:

MySqlConnector.MySqlException : XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected

When debugging I noticed that on Aurora MySQL the issue we saw in #1317 is now occurring on the XA END call rather than the XA ROLLBACK call, causing the code to never call XA ROLLBACK, leaving the connection in an invalid state (causing any subsequent call to keep throwing the above exception).

To ensure compatibility it seems like we need to handle the case for both calls separately in the OnRollback scenario.

@PatrickMNL PatrickMNL changed the title Handle XA_RBDEADLOCK on XA END while still calling XA ROLLBACK afterwards to clean up the connection state (Aurora MySQL). Handle XA_RBDEADLOCK on XA END while still calling XA ROLLBACK afterwards. Sep 2, 2025
@PatrickMNL
Copy link
Contributor Author

Proposal for fixing XA connection state not being reset properly on TransactionScope.Dispose for Aurora MySQL.

Fixes #1590

@bgrainger
Copy link
Member

Thanks for the contribution!

Is it possible to add tests to make this failure happen deterministically (e.g., with the steps given in #1585 (comment)) to verify compatibility (and check for regressions) with the DBs used in the integration tests? (Unfortunately the integration tests don't run against Aurora, but do use MariaDB.)

@PatrickMNL
Copy link
Contributor Author

PatrickMNL commented Sep 4, 2025

Thanks for the response!

We are currently prepping for a production migration to AWS, so I won't be able to add that on the short term, but I am willing to have a go at it somewhere after that, that would hopefully be in 2 weeks or so.

For now we'll use a version build from my fork for the migration (without it Aurora wasn't usable for us).

@bgrainger bgrainger merged commit 728e254 into mysql-net:master Sep 5, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants