Skip to content

Commit

Permalink
Always return real WAL restore error
Browse files Browse the repository at this point in the history
If we return the context error it will be "context canceled" but the
errgroup has the real error. Context should never be canceled unless the
errgroup had errored.
  • Loading branch information
hifi committed Jun 4, 2024
1 parent 5204182 commit 6f08697
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -1233,12 +1233,14 @@ func (r *Replica) Restore(ctx context.Context, opt RestoreOptions) (err error) {
}

// Apply WAL files in order as they are ready.
applyFor:
for index := minWALIndex; index <= maxWALIndex; index++ {
// Wait until next WAL file is ready to apply.
mu.Lock()
for !walStates[index-minWALIndex].ready {
if err := ctx.Err(); err != nil {
return err
mu.Unlock()
break applyFor
}
cond.Wait()
}
Expand Down

0 comments on commit 6f08697

Please sign in to comment.