Skip to content

Commit fe42622

Browse files
committed
native: fix deadlock from leaving transactions open
Signed-off-by: Tonis Tiigi <[email protected]>
1 parent 439316c commit fe42622

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
@@ -150,11 +150,17 @@ func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap
150150

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

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

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

0 commit comments

Comments
 (0)