From ad9eca1dc4838d72a1f882c0cec8ddceb89b8eda Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Tue, 7 Nov 2017 17:25:46 -0800 Subject: [PATCH] Fix deadlock in overlay snapshotter The Usage implementation in the overlay driver allowed returning before Rollback was called, leaving a transaction open and causing further operations to deadlock. This could occur if the usage call to the datastore returned an error, such as not found. Signed-off-by: Derek McGowan --- snapshot/overlay/overlay.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/snapshot/overlay/overlay.go b/snapshot/overlay/overlay.go index 8f0e0d09e..0f800da22 100644 --- a/snapshot/overlay/overlay.go +++ b/snapshot/overlay/overlay.go @@ -124,12 +124,13 @@ func (o *snapshotter) Usage(ctx context.Context, key string) (snapshot.Usage, er return snapshot.Usage{}, err } id, info, usage, err := storage.GetInfo(ctx, key) + t.Rollback() // transaction no longer needed at this point. + if err != nil { return snapshot.Usage{}, err } upperPath := o.upperPath(id) - t.Rollback() // transaction no longer needed at this point. if info.Kind == snapshot.KindActive { du, err := fs.DiskUsage(upperPath)