Skip to content

Commit c5d5315

Browse files
committed
Ignore exception only during rollback. Fixes #1317
1 parent f843137 commit c5d5315

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/MySqlConnector/Core/XaEnlistedTransaction.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,24 @@ protected override void OnCommit(Enlistment enlistment)
3535

3636
protected override void OnRollback(Enlistment enlistment)
3737
{
38-
ExecuteXaCommand("END");
39-
ExecuteXaCommand("ROLLBACK");
40-
}
41-
42-
private void ExecuteXaCommand(string statement)
43-
{
44-
using var cmd = Connection.CreateCommand();
45-
cmd.CommandText = "XA " + statement + " " + m_xid;
4638
try
4739
{
48-
cmd.ExecuteNonQuery();
40+
ExecuteXaCommand("END");
41+
ExecuteXaCommand("ROLLBACK");
4942
}
5043
catch (MySqlException ex) when (ex.ErrorCode is MySqlErrorCode.XARBDeadlock)
5144
{
5245
// ignore deadlock when rolling back
5346
}
5447
}
5548

49+
private void ExecuteXaCommand(string statement)
50+
{
51+
using var cmd = Connection.CreateCommand();
52+
cmd.CommandText = "XA " + statement + " " + m_xid;
53+
cmd.ExecuteNonQuery();
54+
}
55+
5656
private static int s_currentId;
5757

5858
private string? m_xid;

0 commit comments

Comments
 (0)