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 void ExecuteBatch(IUpdateBatch batch) { try { batch.ApplyChanges(this); _retryPolicy.Execute(_connection.Commit); } catch (Exception) { try { _retryPolicy.Execute(_connection.Rollback); } catch (RollbackException e) { if (e.InnerException != null) { Logger.LogFailure(new NpgsqlCommand(), e.InnerException); } } catch (Exception e) { Logger.LogFailure(new NpgsqlCommand(), e); } tryApplyTombstoneBatch(); throw; } }
internal void ExecuteBatch(IUpdateBatch batch) { try { batch.ApplyChanges(this); Database.Commit(); } catch (Exception) { Database.Rollback(); if (Options.EventGraph.TryCreateTombstoneBatch(this, out var tombstoneBatch)) { try { tombstoneBatch.ApplyChanges(this); } 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 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; } }
internal void ExecuteBatch(IUpdateBatch batch) { try { batch.ApplyChanges(this); _retryPolicy.Execute(_connection.Commit); } catch (Exception) { try { _retryPolicy.Execute(_connection.Rollback); } 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 { tombstoneBatch.ApplyChanges(this); _retryPolicy.Execute(_connection.Commit); } catch (Exception e) { Logger.LogFailure(new NpgsqlCommand(), e); } } throw; } }