Skip to content

Commit 034a6be

Browse files
author
Joshua Sierles
committed
Retry backup completion annotations in case there's a race condition preventing them from succeeding
1 parent cd110f1 commit 034a6be

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

percona/controller/pgbackup/controller.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,21 @@ func deleteBackupFinalizer(c client.Client, pg *v2.PerconaPGCluster) func(ctx co
336336
return errors.Wrap(err, "get backup job")
337337
}
338338

339-
rr, err := finishBackup(ctx, c, pgBackup, job)
339+
// Add retries for the finishBackup operation
340+
var rr *reconcile.Result
341+
err = retry.RetryOnConflict(retry.DefaultBackoff, func() error {
342+
var innerErr error
343+
rr, innerErr = finishBackup(ctx, c, pgBackup, job)
344+
if innerErr != nil {
345+
// If the error is about missing annotations, we should retry
346+
if strings.Contains(innerErr.Error(), "backup annotations are not found in pgbackrest") {
347+
return innerErr
348+
}
349+
// For other errors, return them without retrying
350+
return retry.OnError(retry.DefaultBackoff, func(err error) bool { return false }, func() error { return innerErr })
351+
}
352+
return nil
353+
})
340354
if err != nil {
341355
return errors.Wrap(err, "failed to finish backup")
342356
}

0 commit comments

Comments
 (0)