Repository navigation
Exit async archive-push on first error. - #2802
Conversation
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.
|
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 🤔 |
|
Yeah, this was my thinking as well. |
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.