overlay: call rollback on commit error
Rollback was not being called when the function was called with a key which does not exist. This failure to call rollback kept the database open and caused all new requests to block. Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
parent
fa4e114979
commit
7027e8862a
@ -152,6 +152,14 @@ func (o *snapshotter) Commit(ctx context.Context, name, key string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
if rerr := t.Rollback(); rerr != nil {
|
||||||
|
log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
// grab the existing id
|
// grab the existing id
|
||||||
id, _, _, err := storage.GetInfo(ctx, key)
|
id, _, _, err := storage.GetInfo(ctx, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -163,10 +171,7 @@ func (o *snapshotter) Commit(ctx context.Context, name, key string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := storage.CommitActive(ctx, key, name, snapshot.Usage(usage)); err != nil {
|
if _, err = storage.CommitActive(ctx, key, name, snapshot.Usage(usage)); err != nil {
|
||||||
if rerr := t.Rollback(); rerr != nil {
|
|
||||||
log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction")
|
|
||||||
}
|
|
||||||
return errors.Wrap(err, "failed to commit snapshot")
|
return errors.Wrap(err, "failed to commit snapshot")
|
||||||
}
|
}
|
||||||
return t.Commit()
|
return t.Commit()
|
||||||
|
Loading…
Reference in New Issue
Block a user