Skip to content

Commit ebf69b8

Browse files
committed
Handle a MySqlException with error code XAERRemoveFail indicating the XA state is ROLLBACK ONLY.
1 parent 1834cfd commit ebf69b8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/MySqlConnector/Core/XaEnlistedTransaction.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,15 @@ protected override void OnRollback(Enlistment enlistment)
3232
{
3333
try
3434
{
35-
if (!IsPrepared)
36-
ExecuteXaCommand("END");
35+
try
36+
{
37+
if (!IsPrepared)
38+
ExecuteXaCommand("END");
39+
}
40+
catch (MySqlException ex) when (ex.ErrorCode is MySqlErrorCode.XAERRemoveFail && ex.Message.Contains("ROLLBACK ONLY"))
41+
{
42+
// ignore unprepared end failure when XAERRemoveFail is returned telling us the XA state is ROLLBACK ONLY.
43+
}
3744

3845
ExecuteXaCommand("ROLLBACK");
3946
}

0 commit comments

Comments
 (0)