Skip to content

Commit

Permalink
cleanup(gorgone): Avoid double-rollback when db commit fails
Browse files Browse the repository at this point in the history
  • Loading branch information
vuntz committed Jul 27, 2024
1 parent d15b700 commit 0716eb2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions gorgone/gorgone/class/db.pm
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,10 @@ sub commit {
my $status = $self->{instance}->commit();

if (!$status) {
$self->error($self->{instance}->errstr, 'commit');
# Note that the call to error() does a rollback, which is what we want
# in case of failure
# https://stackoverflow.com/questions/24316603/why-should-i-rollback-after-failed-commit
self->rollback();
$self->error($self->{instance}->errstr, 'commit');
return -1;
}

Expand Down

0 comments on commit 0716eb2

Please sign in to comment.