internal async Task ExecuteBatchAsync(IUpdateBatch batch, CancellationToken token) { await BeginTransactionAsync(token).ConfigureAwait(false); try { await batch.ApplyChangesAsync(this, token).ConfigureAwait(false); await _retryPolicy.ExecuteAsync(() => _connection.CommitAsync(token), token).ConfigureAwait(false); } catch (Exception) { try { await _retryPolicy.ExecuteAsync(() => _connection.RollbackAsync(token), token).ConfigureAwait(false); } catch (RollbackException e) { if (e.InnerException != null) { Logger.LogFailure(new NpgsqlCommand(), e.InnerException); } } catch (Exception e) { Logger.LogFailure(new NpgsqlCommand(), e); } await tryApplyTombstoneEvents(token).ConfigureAwait(false); throw; } }
internal async Task ExecuteBatchAsync(IUpdateBatch batch, CancellationToken token) { try { await batch.ApplyChangesAsync(this, token).ConfigureAwait(false); await Database.CommitAsync(token).ConfigureAwait(false); } catch (Exception) { await Database.RollbackAsync(token).ConfigureAwait(false); if (Options.EventGraph.TryCreateTombstoneBatch(this, out var tombstoneBatch)) { try { await tombstoneBatch.ApplyChangesAsync(this, token); } catch (Exception) { // Failures are logged within the ManagedConnection } } throw; } }
internal async Task ExecuteBatchAsync(IUpdateBatch batch, CancellationToken token) { try { await batch.ApplyChangesAsync(this, token).ConfigureAwait(false); await _retryPolicy.ExecuteAsync(() => _connection.CommitAsync(token), token).ConfigureAwait(false); } catch (Exception) { try { await _retryPolicy.ExecuteAsync(() => _connection.RollbackAsync(token), token).ConfigureAwait(false); } catch (RollbackException e) { if (e.InnerException != null) { Logger.LogFailure(new NpgsqlCommand(), e.InnerException); } } catch (Exception e) { Logger.LogFailure(new NpgsqlCommand(), e); } if (Options.EventGraph.TryCreateTombstoneBatch(this, out var tombstoneBatch)) { try { await tombstoneBatch.ApplyChangesAsync(this, token).ConfigureAwait(false); await _retryPolicy.ExecuteAsync(() => _connection.CommitAsync(token), token).ConfigureAwait(false); } catch (Exception e) { Logger.LogFailure(new NpgsqlCommand(), e); } } throw; } }