Skip to content

Commit

Permalink
fix: rollback snapshot to prevent bolt deadlock
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Goller <[email protected]>
  • Loading branch information
goller committed Jul 27, 2023
1 parent 9e9e7a5 commit 3486b7f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion snapshot/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,9 @@ func (o *snapshotter) commit(ctx context.Context, isRemote bool, name, key strin
return err
}

rollback := true
defer func() {
if err != nil {
if rollback {
if rerr := t.Rollback(); rerr != nil {
log.G(ctx).WithError(rerr).Warn("failed to rollback transaction")
}
Expand All @@ -342,6 +343,7 @@ func (o *snapshotter) commit(ctx context.Context, isRemote bool, name, key strin
return fmt.Errorf("failed to commit snapshot: %w", err)
}

rollback = false
return t.Commit()
}

Expand Down

0 comments on commit 3486b7f

Please sign in to comment.