Skip to content

Commit

Permalink
native: fix deadlock from leaving transactions open
Browse files Browse the repository at this point in the history
Signed-off-by: Tonis Tiigi <[email protected]>
(cherry picked from commit fe42622)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
tonistiigi authored and thaJeztah committed Mar 24, 2022
1 parent 8a36855 commit 28b4482
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions snapshots/native/native.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,17 @@ func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap

id, _, _, err := storage.GetInfo(ctx, key)
if err != nil {
if rerr := t.Rollback(); rerr != nil {
log.G(ctx).WithError(rerr).Warn("failed to rollback transaction")
}
return err
}

usage, err := fs.DiskUsage(ctx, o.getSnapshotDir(id))
if err != nil {
if rerr := t.Rollback(); rerr != nil {
log.G(ctx).WithError(rerr).Warn("failed to rollback transaction")
}
return err
}

Expand Down Expand Up @@ -281,6 +287,9 @@ func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k
fs.WithXAttrErrorHandler(xattrErrorHandler),
}
if err := fs.CopyDir(td, parent, copyDirOpts...); err != nil {
if rerr := t.Rollback(); rerr != nil {
log.G(ctx).WithError(rerr).Warn("failed to rollback transaction")
}
return nil, fmt.Errorf("copying of parent failed: %w", err)
}
}
Expand Down

0 comments on commit 28b4482

Please sign in to comment.