overlay: fix cleanup directory deletion race

Fixes a bug where a writable transaction may create or make changes to
a directory while the cleanup is running, leading to removal of a
directory which will be referenced.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan 2018-03-14 13:36:49 -07:00
parent b307df2723
commit 94cf25f7db
No known key found for this signature in database
GPG Key ID: F58C5D0A4405ACDB

View File

@ -309,7 +309,9 @@ func (o *snapshotter) Cleanup(ctx context.Context) error {
} }
func (o *snapshotter) cleanupDirectories(ctx context.Context) ([]string, error) { func (o *snapshotter) cleanupDirectories(ctx context.Context) ([]string, error) {
ctx, t, err := o.ms.TransactionContext(ctx, false) // Get a write transaction to ensure no other write transaction can be entered
// while the cleanup is scanning.
ctx, t, err := o.ms.TransactionContext(ctx, true)
if err != nil { if err != nil {
return nil, err return nil, err
} }