You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: pg_wal not symlinked to the WAL volume during plugin-based recovery, filling the data volume #11125
I have searched for an existing issue, and could not find anything. I believe this is a new bug.
I have read the troubleshooting guide
I have read the troubleshooting guide and I think this is a new bug.
I am running a supported version of CloudNativePG
I have read the troubleshooting guide and I think this is a new bug.
Contact Details
No response
Version
trunk (main)
What version of Kubernetes are you using?
1.33
What is your Kubernetes environment?
Cloud: Other
How did you install the operator?
YAML manifest
What happened?
When recovering a cluster that has a dedicated WAL volume through a recovery plugin (CNPG-I, e.g. the Barman Cloud plugin), the recovery job never turns $PGDATA/pg_wal into a symlink pointing at the WAL volume. WAL replay runs inside the recovery job with pg_wal still a real directory on the data volume, so every WAL fetched by restore_command during recovery accumulates on the data volume instead of the (generously sized) WAL volume. On a large PITR this exhausts the data volume and the recovery fails, even though the WAL volume has plenty of free space and sits unused.
The layout is only corrected later: when the recovery job finishes and the instance restarts as a normal pod, ReconcileWalDirectory moves pg_wal onto the WAL volume and creates the symlink before Postgres starts. By then the data volume may already be full.
The in-tree (non-plugin) recovery path is not affected: it sets up the pg_wal symlink before WAL replay begins, so WALs land on the WAL volume as expected during the recovery job.
Expected: with a dedicated WAL volume, plugin-based recovery should place pg_wal on the WAL volume before replaying WALs, matching the in-tree recovery behavior.
Cluster resource
A cluster with .spec.walStorage set and .spec.bootstrap.recovery sourced from a plugin (e.g. barman-cloud.cloudnative-pg.io).
I can confirm the root cause from the code. The divergence happens in the Restore() function in pkg/management/postgres/restore.go[1]:
In-tree path: after restoring the data directory, explicitly calls restoreCustomWalDir()[2] which creates the symlink from $PGDATA/pg_wal → /var/lib/postgresql/wal/pg_wal before WAL replay begins.
Plugin path: calls restoreViaPlugin()[3] and proceeds directly to concludeRestore() — never calls restoreCustomWalDir().
The ReconcileWalDirectory() in pkg/reconciler/instance/storage/reconciler.go[4] only runs at normal instance startup [5], which is after the recovery job finishes — too late for PITR WAL replay.
This matches the pattern from prior fixes where plugin recovery missed safeguards present in in-tree recovery, e.g. PR #9306[6] which fixed sentinel file creation being skipped during plugin-based volume snapshot recovery.
The most straightforward fix would be to call restoreCustomWalDir() after restoreViaPlugin() returns (before concludeRestore() kicks off replay), so the WAL volume is properly symlinked regardless of whether recovery was plugin- or in-tree-driven.
Activity
dosubot commentedon Jul 3, 2026
I can confirm the root cause from the code. The divergence happens in the
Restore()function inpkg/management/postgres/restore.go[1]:restoreCustomWalDir()[2] which creates the symlink from$PGDATA/pg_wal→/var/lib/postgresql/wal/pg_walbefore WAL replay begins.restoreViaPlugin()[3] and proceeds directly toconcludeRestore()— never callsrestoreCustomWalDir().The
ReconcileWalDirectory()inpkg/reconciler/instance/storage/reconciler.go[4] only runs at normal instance startup [5], which is after the recovery job finishes — too late for PITR WAL replay.This matches the pattern from prior fixes where plugin recovery missed safeguards present in in-tree recovery, e.g. PR #9306 [6] which fixed sentinel file creation being skipped during plugin-based volume snapshot recovery.
The most straightforward fix would be to call
restoreCustomWalDir()afterrestoreViaPlugin()returns (beforeconcludeRestore()kicks off replay), so the WAL volume is properly symlinked regardless of whether recovery was plugin- or in-tree-driven.To reply, just mention @dosu.
Docs are dead. Just use Dosu.
fix(recovery): symlink pg_wal to the WAL volume during plugin recovery
fix(recovery): symlink pg_wal to the WAL volume during plugin recovery (
fix(recovery): symlink pg_wal to the WAL volume during plugin recovery (
fix(recovery): symlink pg_wal to the WAL volume during plugin recovery (
fix(recovery): symlink pg_wal to the WAL volume during plugin recovery (