Skip to content

fix(walrestore): use timeline-aware barman-cloud end-of-WAL markers - #993

Merged
mnencia merged 6 commits into
cloudnative-pg:mainfrom
ardentperf:pr-fix-end-of-wal
Oct 21, 2026
Merged

mnencia merged 6 commits into
cloudnative-pg:mainfrom
ardentperf:pr-fix-end-of-wal

Conversation

@ardentperf

@ardentperf ardentperf commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

A global end-of-WAL marker can be set by a parent-timeline prefetch miss and then consumed by a child-timeline restore request. In snapshot-restored replica flows, that can cause PostgreSQL to miss valid child-timeline WAL and replay wrong parent-timeline bytes. Reference cloudnative-pg/barman-cloud#276

Update wal-restore to use the timeline-aware barman-cloud restorer APIs (ConsumeEndOfWALStreamForWAL, SetEndOfWALStreamFromResults). In pg_rewind mode, ClearEndOfWALStream now discards the markers of every timeline. This also drops the nolint markers for the deprecated calls.

@ardentperf
ardentperf requested a review from a team July 6, 2026 16:15
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working go Pull requests that update go code labels Jul 6, 2026
@jmealo

jmealo commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

👍 LGTM

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 8, 2026
@armru
armru self-requested a review July 9, 2026 11:49
@mnencia
mnencia requested a review from a team as a code owner October 15, 2026 10:35
@mnencia
mnencia force-pushed the pr-fix-end-of-wal branch 2 times, most recently from e9318ca to f15d62f Compare October 15, 2026 15:42
@mnencia
mnencia force-pushed the pr-fix-end-of-wal branch 2 times, most recently from 64058da to b3ff623 Compare October 20, 2026 13:14
mnencia added a commit that referenced this pull request Oct 20, 2026
Revert the end-of-wal-stream API migration, which #993 already carries,
and suppress the staticcheck deprecation warnings meanwhile.

Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
mnencia added a commit that referenced this pull request Oct 20, 2026
The end-of-wal-stream API migration is already carried by #993. Suppress the staticcheck deprecation warnings meanwhile.

Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
ardentperf and others added 5 commits October 20, 2026 18:54
Update `wal-restore` to use the new `barman-cloud` restorer APIs,
resolving a bug that can cause replicas to enter a broken state that
CNPG cant recover from. Local marker naming, WAL timeline parsing, and
restore-result filtering policy lives in
`github.com/cloudnative-pg/barman-cloud/pkg/restorer`. depends on
cloudnative-pg/barman-cloud#277

Signed-off-by: Jeremy Schneider <schneider@ardentperf.com>
Use ClearEndOfWALStream from barman-cloud for pg_rewind restores. It
also clears the timeline-scoped markers and avoids the deprecated
legacy calls. Move the fork pin to the commit that adds it.

Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
The segments of this test are on timeline 1.

Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
At the first segment of a new timeline PostgreSQL requests the
child-timeline file and, if that fails, falls back to the
parent-timeline one, which holds WAL past the switch point. Request a
child-timeline segment while the parent-timeline end-of-wal-stream flag
is set, and check that it is restored and the flag is left alone. This
covers the plugin side of cloudnative-pg/barman-cloud#276: a
timeline-blind flag check fails the request.

Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
The clearEndOfWALStreamFlag tests went away with the helper, so nothing
checked that a pg_rewind restore discards the timeline-scoped flags too,
nor that it does so before serving a WAL file from the spool. Cover both
through restoreFromBarmanObjectStore, using a spool hit so no download
runs.

Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
Pin the call site of ConsumeEndOfWALStreamForWAL: the flag is scoped to
the timeline of the requested WAL and consumed once. Also tighten the
related comments.

Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
@mnencia
mnencia merged commit f46d2fc into cloudnative-pg:main Oct 21, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants