Skip to content

[Feat]: Fix WAL-full condition blocking automatic walStorage PVC resize #11341

Description

@JamesatStarling

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

1.30.0

What version of Kubernetes are you using?

1.35

What is your Kubernetes environment?

Cloud: Amazon EKS

How did you install the operator?

YAML manifest

What happened?

When a cluster hits WAL disk exhaustion, increasing spec.walStorage.size on the cluster resource does not automatically resize the WAL PVC.

Observed Behavior:

  1. Cluster entered/stayed in a Not enough disk space state.
  2. Controller kept reporting WAL space exhaustion.
  3. WAL PVC size did not change from the old value after updating cluster spec.
  4. Manual patching of the WAL PVC request size was required to recover.
  5. After manual WAL PVC patch, reconciliation resumed and other pending size changes for example a data PVC was then applied automatically.

Impact:

  • Recovery from WAL-full required manual intervention.
  • This blocked the expected declarative workflow, spec.walStorage.size change should be enough.

Likely Cause:

  • Reconciliation was short-circuited by the WAL disk full guard before PVC resize reconciliation could run, creating an ordering deadlock in this failure mode.

Expected Behaviour:

When WAL storage is full and the user increases spec.walStorage.size the order of execution is:

  1. PVC resize reconciliation runs first.
  2. WAL PVC size request is patched automatically from cluster spec.
  3. Disk full guard may still re-queue while the storage backend completes expansion, but resize is already in progress.
  4. Once expansion is applied by Kubernetes/storage class, the instance recovers without manual PVC patching.

Cluster resource

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added
    bug 🐛
    triage
    on Aug 19, 2026
  2. dosubot commented on Aug 19, 2026

    @dosubot

    @JamesatStarling, your analysis is correct — the code confirms the ordering deadlock you described. Here's the breakdown:

    1. ensureNoFailoverOnFullDisk runs in the reconcile function and, when it detects any pod with insufficient WAL space (via isWALSpaceAvailableOnPod), it registers the phase "Not enough disk space" and immediately returns RequeueAfter: 10 * time.Second [1].

    2. persistentvolumeclaim.Reconcile — the function that would actually resize the WAL PVC to match spec.walStorage.size — runs inside reconcileResources, which is called much later at line 594.

    3. Because the disk-full guard returns early in step 1, reconcileResources is never reached. The PVC resize is skipped on every cycle, and the cluster stays stuck in "Not enough disk space".

    The fix would involve moving the PVC resize step (or at least the quantity-resize portion) to execute before the ensureNoFailoverOnFullDisk guard, so the WAL PVC request gets patched in Kubernetes and the CSI resizer can act even while the instance is in the disk-full state.

    Workaround: You only need to manually patch the stuck instance's WAL PVC. Once that pod comes back to Ready, the operator resumes normal reconciliation and handles any remaining PVC resizes on its own [2]:

    kubectl patch pvc <wal-pvc-name> -n <namespace> --type merge \
      -p '{"spec":{"resources":{"requests":{"storage":"<new-size>"}}}}'

    To reply, just mention @dosu.


    Docs are dead. Just use Dosu.

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

  3. JamesatStarling commented on Sep 8, 2026

    @JamesatStarling
    Author

    For reference I've opened a pull request with a suggested fix here: fix: reconcile WAL PVC resize before disk-full guard

  4. added this to the Now milestone on Sep 21, 2026
  5. GellertBabel commented on Oct 1, 2026

    @GellertBabel
    Contributor

    After looking at the PR quickly then and now looked more carefully I realized this is not a bug but a feature request. I think this can be an improvement but needs to proceed carefully as this shouldn't boil down to just always reconcile the pvc change first.
    My suggestion is to convert the ticket into a feature and align with the maintainers on the direction.

  6. changed the title [-][Bug]: Fix WAL-full condition blocking automatic walStorage PVC resize[/-] [+][Feat]: Fix WAL-full condition blocking automatic walStorage PVC resize[/+] on Oct 5, 2026
  7. JamesatStarling commented on Oct 9, 2026

    @JamesatStarling
    Author

    After further reviewing and discussions with @GellertBabel it appears this isn't actually a bug, but rather a desired enhancement/feature. Could a maintainer please swap the bug label for a feature/enhancement label?

  8. JamesatStarling commented on Oct 22, 2026

    @JamesatStarling
    Author

    Thanks for the review, my first attempt moved ReconcileExistingPVCs ahead of ensureNoFailoverOnFullDisk unconditionally. I agree that is too broad, and I'd like to agree on a narrower design before reworking the PR.

    Problem:

    When WAL space is exhausted, ensureNoFailoverOnFullDisk registers the "Not enough disk space" phase and requeues. It returns before PVC reconciliation runs. A user who increases walStorage.size to recover therefore has no change applied while the cluster is stuck.

    Why the first attempt was too broad:

    • It changed the ordering for every cluster on every reconcile, not just clusters that are disk-full.
    • ReconcileExistingPVCs runs every reconciliation unit, so reconcileVolumeAttributeClass was also moved ahead of the guard. That is unrelated to disk-full recovery.
    • It covers PVCs of all roles, whether or not they are the volume that is out of space.
    • It runs ReconcileExistingPVCs twice per reconcile, because reconcile still calls it later.

    What the detection can and can't tell us:

    • isWALSpaceAvailableOnPod only checks whether the postgres container terminated with MissingWALDiskSpaceExitCode.
    • That exit code comes from CheckHasDiskSpaceForWAL, which probes PGDATA/pg_wal for room for one WAL segment.
    • So it detects "the filesystem under pg_wal is full". That is the WAL PVC when walStorage is set, and the data PVC otherwise.
    • It can't say which volume is full.

    Proposed design:

    1. Conditional. Run the resize-first path only when isWALSpaceAvailableOnPod reports a pod without WAL space. Otherwise the ordering is unchanged.
    2. Resize only. Expose a quantity-only entry point (for example ReconcilePVCQuantities) instead of the full ReconcileExistingPVCs. Volume attributes class changes and any future units stay after the guard.
    3. Scoped to the volume holding pg_wal. Patch the WAL PVCs when walStorage is configured, and the data PVCs otherwise.
    4. Guard stays intact. After the resize patch, execution continues into ensureNoFailoverOnFullDisk, rather than returning early. The guard returns before replicaclusterswitch, handleSwitchover and reconcileResources, which is where a new target primary gets chosen. Skipping it would allow a failover while the disk is full. The resize is reported through an event and the phase message.
    5. Existing preconditions apply. ShouldResizeInUseVolumes(), the "cannot decrease" check, and allowVolumeExpansion on the storage class all still gate the patch. Unsupported cases should fail visibly.

    Open questions for the maintainers:

    • Is a resize exception to the guard acceptable at all, or should disk-full recovery remain a documented manual step?
    • Is the scope in point 3 right?
    • Are there failover concerns with patching PVCs while the guard is open that I haven't considered?
    • If the filesystem resize requires a running pod and the pod is crash-looping on the full disk, is documenting that limitation enough?

    Tests planned:

    • Healthy cluster: ordering unchanged, nothing extra patched.
    • WAL disk-full with an increased walStorage.size: the PVC is patched and the guard still reports the phase.
    • Disk-full with no walStorage: the data PVC is resized.
    • Disk-full plus a volume attributes class change: the class change is not applied early.
    • No failover is triggered while the guard is active after the resize.
    • Patch error or conflict: handled as today.

    If the direction looks right, I'll rework the PR along these lines. If not, I'm happy to close it and write this up as documentation.

  9. JamesatStarling commented on Nov 24, 2026

    @JamesatStarling
    Author

    @GellertBabel How does the above sound? Does this need to be discussed elsewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐛triage

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions