Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,19 @@ await Client.Transactions.RunInTransactionAsync<int>(async tx =>
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ public async Task CommitAsync()
/// <inheritdoc/>
public async Task RollbackAsync()
{
if (TrySetState(StateRolledBack))
if (!TrySetState(StateRolledBack))
{
return;
}

try
{
var tx = await DoOpAsync(_tx, ClientOp.TxRollback).ConfigureAwait(false);

Expand All @@ -117,6 +122,10 @@ public async Task RollbackAsync()
_logger.LogTxRollbackTrace(tx.Id);
}
}
catch (IgniteClientConnectionException)
{
// Connection exception: tx rolled back on server. Ignore.
}
}

/// <inheritdoc/>
Expand Down