feat(wal): add restore mode to WALRestoreRequest#351
Open
armru wants to merge 1 commit into
Open
Conversation
The operator can now tell WAL restore plugins whether a WAL file is being restored by an instance in recovery or on behalf of pg_rewind, which requires fetching exactly the requested file, without WAL prefetching and without caching archive misses observed on nearby segments. Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
mnencia
force-pushed
the
dev/wal-restore-rewind-mode
branch
from
July 17, 2026 08:41
10dead4 to
80f3079
Compare
mnencia
pushed a commit
to cloudnative-pg/plugin-barman-cloud
that referenced
this pull request
Jul 17, 2026
The operator now tells WAL restore plugins when a restore request is made on behalf of pg_rewind (cloudnative-pg/cnpg-i#351). pg_rewind walks the timeline backwards, fetches every WAL file it needs exactly once, and treats any restore failure as fatal, so both optimizations meant for an instance in recovery must stay off: prefetching the following segments is wasted work that ends in an archive miss, and the end-of-wal-stream flag recorded by such a miss makes a later invocation fail on a segment that is available in the archive, aborting the whole rewind. The cnpg-i dependency points to a pseudo-version of that pull request and will be moved to the next tagged release once it is available. Ref: cloudnative-pg/cloudnative-pg#11200 Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
mnencia
approved these changes
Jul 17, 2026
mnencia
pushed a commit
to cloudnative-pg/plugin-barman-cloud
that referenced
this pull request
Jul 17, 2026
The operator now tells WAL restore plugins when a restore request is made on behalf of pg_rewind (cloudnative-pg/cnpg-i#351). pg_rewind walks the timeline backwards, fetches every WAL file it needs exactly once, and treats any restore failure as fatal, so both optimizations meant for an instance in recovery must stay off: prefetching the following segments is wasted work that ends in an archive miss, and the end-of-wal-stream flag recorded by such a miss makes a later invocation fail on a segment that is available in the archive, aborting the whole rewind. The cnpg-i dependency points to a pseudo-version of that pull request and will be moved to the next tagged release once it is available. Ref: cloudnative-pg/cloudnative-pg#11200 Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pg_rewind fetches the WAL files it needs by running the cluster's
restore_command, and when WAL restore is handled by a plugin those invocations reach the plugin with no way to tell that pg_rewind, and not an instance in recovery, is asking. The difference matters: pg_rewind walks the timeline backwards, fetches every file exactly once, and treats any restore failure as fatal, so the optimizations a plugin applies during recovery, like prefetching the following segments or caching an archive miss to signal the end of the WAL stream, actively break it. cloudnative-pg/cloudnative-pg#11200 shows the resulting failure on the in-tree restore path, fixed by cloudnative-pg/cloudnative-pg#11204; plugins need this field to do the same.WALRestoreRequestgains amodefield stating the context the WAL file is being restored in.MODE_REWINDasks the plugin to retrieve exactly the requested file, without prefetching and without caching archive misses.MODE_UNSPECIFIEDis what an operator predating the field sends and must be read asMODE_RECOVERY. The field is optional, so older operators and older plugins keep their current behavior.Part of cloudnative-pg/cloudnative-pg#11200.