From e0507dcd784e0d9380c98c216babe1c25b30e2df Mon Sep 17 00:00:00 2001 From: Toni Spets Date: Fri, 12 Apr 2024 16:41:55 +0300 Subject: [PATCH] Always return real WAL restore error 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. --- replica.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/replica.go b/replica.go index 1e51fe86..9ed2fd58 100644 --- a/replica.go +++ b/replica.go @@ -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() }