Skip to content

Exit async archive-push on first error. - #2802

Merged
dwsteele merged 5 commits into
pgbackrest:integrationfrom
dwsteele:dev-archive-err-check
Jul 3, 2026
Merged

dwsteele merged 5 commits into
pgbackrest:integrationfrom
dwsteele:dev-archive-err-check

Conversation

@dwsteele

@dwsteele dwsteele commented Jul 2, 2026

Copy link
Copy Markdown
Member

When the repository was unavailable the async archive-push process kept trying every ready WAL segment, retrying each failure and writing an error file for it. Because the archive queue is only checked at the start of each run, a run could take so long that the WAL volume filled and PostgreSQL stopped before archive-push-queue-max was rechecked.

Exit the run as soon as any job errors so the async process is respawned by the next archive-push, which rechecks the queue and drops WAL once it exceeds archive-push-queue-max. Continuing past an error cannot relieve disk pressure because PostgreSQL cannot recycle any WAL past the oldest unarchived segment, so the segments pushed ahead free nothing; the only relief is the queue-max drop. job-retry already absorbs transient failures before they are reported here, so a reported error is a real failure and there is little benefit to continuing.

In-flight jobs are allowed to finish so their status is recorded and no segment is pushed twice.

dwsteele added 3 commits July 2, 2026 18:45
When the repository is unavailable the async archive-push process kept trying every ready WAL segment, retrying each one and writing an error file for it, which could take a very long time. Since the archive queue is only checked at the start of each run, the run could outlast the free space on the WAL volume and fill it before archive-push-queue-max was rechecked, stopping PostgreSQL.

Stop the run after three errors so the async process exits promptly and is respawned by the next archive-push, which rechecks the queue and drops WAL once it exceeds archive-push-queue-max. This also avoids writing an error file for every unarchivable segment during an outage.

In-flight jobs are allowed to finish, and runs with fewer errors are unaffected, so archiving still continues past a small number of isolated errors as before.
Stopping after three errors still allowed a run to continue for a long time when only one or two segments failed, and a single early failure followed by the queue outgrowing the push rate could fill the WAL volume before the queue was rechecked at the start of the next run.

Exit as soon as any job errors instead. Continuing past an error cannot relieve disk pressure because PostgreSQL cannot recycle any WAL past the oldest unarchived segment, so the pushed-ahead segments free nothing; the only relief is the queue-max drop, which is re-evaluated when the next run starts. job-retry already absorbs transient failures before they are reported here, so a reported error is a real failure and there is no benefit to waiting for more.
Comment thread src/command/archive/push/push.c Resolved

@pgstef pgstef left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@dwsteele

dwsteele commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

The disadvantage here is that we are not "working ahead" so when the error is cleared there is more WAL to deal with. On the other hand, there's a good chance that WAL will either a) not be useful because there is a unrecoverable error, e.g. duplicate WAL, leading to a GAP or b) the issue is a general error that will cause all WAL segments to error out.

@pgstef

pgstef commented Jul 3, 2026

Copy link
Copy Markdown
Member

The disadvantage here is that we are not "working ahead" so when the error is cleared there is more WAL to deal with. On the other hand, there's a good chance that WAL will either a) not be useful because there is a unrecoverable error, e.g. duplicate WAL, leading to a GAP or b) the issue is a general error that will cause all WAL segments to error out.

In practice, I also believe that the chances of only a single WAL segment failing are lower than the chances of encountering a general error (e.g. a repository permission or availability issue). So having to deal with a bit more work on the next run doesn't seem like a significant overhead compared to protecting against pg_wal exhaustion sooner 🤔

@dwsteele

dwsteele commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

Yeah, this was my thinking as well.

@dwsteele dwsteele changed the title Exit async archive-push on the first error. Exit async archive-push on first error. Jul 3, 2026
@dwsteele
dwsteele merged commit a0c1435 into pgbackrest:integration Jul 3, 2026
35 of 36 checks passed
@dwsteele
dwsteele deleted the dev-archive-err-check branch July 3, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Archive Queue Max doesn't apply when archiving failed

2 participants