Skip to content

Commit

Permalink
fix: Fixed transaction rollback in validate command
Browse files Browse the repository at this point in the history
  • Loading branch information
wwoytenko committed Aug 14, 2024
1 parent 9580584 commit 012c5d5
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 012c5d5

Please sign in to comment.