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 <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan 2017-11-07 17:25:46 -08:00
parent 59d1c16666
commit ad9eca1dc4
No known key found for this signature in database
GPG Key ID: F58C5D0A4405ACDB

View File

@ -124,12 +124,13 @@ func (o *snapshotter) Usage(ctx context.Context, key string) (snapshot.Usage, er
return snapshot.Usage{}, err return snapshot.Usage{}, err
} }
id, info, usage, err := storage.GetInfo(ctx, key) id, info, usage, err := storage.GetInfo(ctx, key)
t.Rollback() // transaction no longer needed at this point.
if err != nil { if err != nil {
return snapshot.Usage{}, err return snapshot.Usage{}, err
} }
upperPath := o.upperPath(id) upperPath := o.upperPath(id)
t.Rollback() // transaction no longer needed at this point.
if info.Kind == snapshot.KindActive { if info.Kind == snapshot.KindActive {
du, err := fs.DiskUsage(upperPath) du, err := fs.DiskUsage(upperPath)