Skip to content

Commit

Permalink
Remove commit if branch update fails (#4290)
Browse files Browse the repository at this point in the history
Add logic to remove a commit that fails to update to the branch tip, not
just when the commit points to a stale branch tip.
  • Loading branch information
mattnibs authored Dec 30, 2022
1 parent 953c58c commit 5ee342c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lake/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,12 @@ func (b *Branch) commit(ctx context.Context, create constructor) (ksuid.KSUID, e
return false
}
if err := b.pool.branches.Update(ctx, config, parentCheck); err != nil {
// Branch update failed so remove commit.
rmerr := b.pool.commits.Remove(ctx, object)
if err == journal.ErrConstraint {
// Parent check failed so try again.
if err := b.pool.commits.Remove(ctx, object); err != nil {
return ksuid.Nil, err
if rmerr != nil {
return ksuid.Nil, rmerr
}
continue
}
Expand Down

0 comments on commit 5ee342c

Please sign in to comment.