Skip to content

[Bug]: pg_wal not symlinked to the WAL volume during plugin-based recovery, filling the data volume #11125

Description

@mnencia

Is there an existing issue already for this bug?

  • 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).

Relevant log output

No response

Activity

  1. added
    bug 🐛
    triage
    on Jul 3, 2026
  2. dosubot commented on Jul 3, 2026

    @dosubot

    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.

    To reply, just mention @dosu.


    Docs are dead. Just use Dosu.

    Leave Feedback Ask Dosu about cloudnative-pg Share Dosu with your team

  3. removed
    triage
    on Jul 5, 2026
  4. added theissue type on Jul 5, 2026
  5. self-assigned this
    on Jul 5, 2026
  6. added a commit that references this issue on Jul 6, 2026
    4d266a6
  7. added 3 commits that reference this issue on Jul 6, 2026
    57ea195
    27463b2
    c5aa344
  8. added a commit that references this issue on Jul 6, 2026
    c591bfb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐛

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions