This is an automated email from the ASF dual-hosted git repository.
ptupitsyn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new 3acbf3e09f6 IGNITE-28106 .NET: Fix tx rollback to ignore connection
errors (#7732)
3acbf3e09f6 is described below
commit 3acbf3e09f691033f84e0bb6f0799be17f53be7a
Author: Pavel Tupitsyn <[email protected]>
AuthorDate: Mon Mar 9 13:21:17 2026 +0100
IGNITE-28106 .NET: Fix tx rollback to ignore connection errors (#7732)
---
.../Apache.Ignite.Tests/Transactions/TransactionsTests.cs | 13 +++++++++++++
.../Apache.Ignite/Internal/Transactions/LazyTransaction.cs | 11 ++++++++++-
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git
a/modules/platforms/dotnet/Apache.Ignite.Tests/Transactions/TransactionsTests.cs
b/modules/platforms/dotnet/Apache.Ignite.Tests/Transactions/TransactionsTests.cs
index f8b45791134..4b9074b6f16 100644
---
a/modules/platforms/dotnet/Apache.Ignite.Tests/Transactions/TransactionsTests.cs
+++
b/modules/platforms/dotnet/Apache.Ignite.Tests/Transactions/TransactionsTests.cs
@@ -415,6 +415,19 @@ namespace Apache.Ignite.Tests.Transactions
Assert.IsFalse(hasVal);
}
+ [Test]
+ public async Task TestRollBackOnClosedConnectionDoesNotThrow()
+ {
+ using var client = await IgniteClient.StartAsync(GetConfig());
+ await using var tx = await client.Transactions.BeginAsync();
+ await TestUtils.ForceLazyTxStart(tx, client);
+
+ // ReSharper disable once DisposeOnUsingVariable
+ client.Dispose();
+
+ Assert.DoesNotThrowAsync(() => tx.RollbackAsync());
+ }
+
private class CustomTx : ITransaction
{
public bool IsReadOnly => false;
diff --git
a/modules/platforms/dotnet/Apache.Ignite/Internal/Transactions/LazyTransaction.cs
b/modules/platforms/dotnet/Apache.Ignite/Internal/Transactions/LazyTransaction.cs
index 993d4ea569b..ff1465f451c 100644
---
a/modules/platforms/dotnet/Apache.Ignite/Internal/Transactions/LazyTransaction.cs
+++
b/modules/platforms/dotnet/Apache.Ignite/Internal/Transactions/LazyTransaction.cs
@@ -108,7 +108,12 @@ internal sealed class LazyTransaction : ITransaction
/// <inheritdoc/>
public async Task RollbackAsync()
{
- if (TrySetState(StateRolledBack))
+ if (!TrySetState(StateRolledBack))
+ {
+ return;
+ }
+
+ try
{
var tx = await DoOpAsync(_tx,
ClientOp.TxRollback).ConfigureAwait(false);
@@ -117,6 +122,10 @@ internal sealed class LazyTransaction : ITransaction
_logger.LogTxRollbackTrace(tx.Id);
}
}
+ catch (IgniteClientConnectionException)
+ {
+ // Connection exception: tx rolled back on server. Ignore.
+ }
}
/// <inheritdoc/>