Skip to content

Commit 603ef55

Browse files
tonistiigithaJeztah
authored andcommitted
native: fix deadlock from leaving transactions open
Signed-off-by: Tonis Tiigi <[email protected]> (cherry picked from commit fe42622) Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 3df54a8 commit 603ef55

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

snapshots/native/native.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,17 @@ func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap
151151

152152
id, _, _, err := storage.GetInfo(ctx, key)
153153
if err != nil {
154+
if rerr := t.Rollback(); rerr != nil {
155+
log.G(ctx).WithError(rerr).Warn("failed to rollback transaction")
156+
}
154157
return err
155158
}
156159

157160
usage, err := fs.DiskUsage(ctx, o.getSnapshotDir(id))
158161
if err != nil {
162+
if rerr := t.Rollback(); rerr != nil {
163+
log.G(ctx).WithError(rerr).Warn("failed to rollback transaction")
164+
}
159165
return err
160166
}
161167

@@ -282,6 +288,9 @@ func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k
282288
fs.WithXAttrErrorHandler(xattrErrorHandler),
283289
}
284290
if err := fs.CopyDir(td, parent, copyDirOpts...); err != nil {
291+
if rerr := t.Rollback(); rerr != nil {
292+
log.G(ctx).WithError(rerr).Warn("failed to rollback transaction")
293+
}
285294
return nil, errors.Wrap(err, "copying of parent failed")
286295
}
287296
}

0 commit comments

Comments
 (0)