Skip to content

Commit

Permalink
Merge pull request #159 from GreenmaskIO/fix/validate_command_transac…
Browse files Browse the repository at this point in the history
…tion_rollback

fix: Fixed transaction rollback in validate command
  • Loading branch information
wwoytenko authored Aug 14, 2024
2 parents 9580584 + 012c5d5 commit eb44dc1
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions internal/db/postgres/cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,9 @@ func (d *Dump) validateDumpWorker(
Msgf("dumping started")

entry, err := func() (entries.Entry, error) {
// We do not need to manage transaction in case of validation - we just close the connection. According to the
// documentation, the COPY stream can be interrupted by the client via connection close.
// If you try to roll back the transaction we will face the deadlock.
conn, tx, err := d.getWorkerTransaction(ctx)

if err != nil {
Expand All @@ -620,12 +623,6 @@ func (d *Dump) validateDumpWorker(
}
}()

defer func() {
if err := tx.Rollback(ctx); err != nil {
log.Debug().Err(err).Int("WorkerId", id).Msg("unable to rollback transaction")
}
}()

entry, err := task.Execute(ctx, tx, d.st)
if err != nil {
return nil, err
Expand Down

0 comments on commit eb44dc1

Please sign in to comment.