Skip to content

fix(core): support immediate backup from a replica cluster - #201

Open
gabriele-wolfox wants to merge 1 commit into
mainfrom
dev/169
Open

fix(core): support immediate backup from a replica cluster#201
gabriele-wolfox wants to merge 1 commit into
mainfrom
dev/169

Conversation

@gabriele-wolfox

@gabriele-wolfox gabriele-wolfox commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

An immediate backup on a freshly-created replica cluster could hang forever, waiting for WAL files that would never be archived.

With no prior archive to resume from, the WAL streamer of the designated primary started from the current flush position, while pg_backup_start on the underlying standby reports the older last-restartpoint LSN.
The WAL segments in between were never covered by tier1.

Start WAL streaming from the redo point of the latest checkpoint (the latest restartpoint on a standby) instead, so tier1 always covers the WAL a backup needs. As a safety net, the server now fails a backup that requires a WAL predating the earliest archived segment, rather than letting the client wait indefinitely.

Adds an e2e scenario that takes an immediate backup from a replica cluster and asserts it completes.

Closes #169

On a freshly-created replica cluster, an immediate backup could hang
forever. With no prior archive to resume from, the WAL streamer of the
designated primary started from the current flush position, while
pg_backup_start on the underlying standby reports the last replayed
restartpoint, which lags behind. The WAL segments between the two were
never archived to tier1, so the backup waited for WAL files that would
never arrive.

Start WAL streaming from the redo point of the latest checkpoint (the
latest restartpoint on a standby) instead of the current flush position.
That redo point is the earliest LSN a later pg_backup_start on the same
instance can report as a backup start, so tier1 always covers the WAL a
backup needs.

As a safety net, fail the backup with a terminal error when a required
WAL predates the earliest archived segment, and can therefore never be
archived, instead of letting the client wait indefinitely.

Add an e2e scenario that takes an immediate backup from a replica
cluster and asserts it completes.

Assisted-by: Claude
Signed-off-by: Gabriele Quaresima <gabriele.quaresima@enterprisedb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Immediate backup from replica cluster fails

1 participant