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 <tonistiigi@gmail.com>
(cherry picked from commit fe42622)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
tonistiigi authored and thaJeztah committed Mar 24, 2022
1 parent 3df54a8 commit 603ef55
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 @@ -151,11 +151,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 @@ -282,6 +288,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, errors.Wrap(err, "copying of parent failed")
}
}
Expand Down

0 comments on commit 603ef55

Please sign in to comment.