PostgreSQL Volume Filling Up

Problem Description

The KubePersistentVolumeFillingUp alert fires for one or several PostgreSQL volumes (pgdata-artesca-postgres-X) in the artesca-auth namespace. If the volumes reach 100% usage, PostgreSQL stops. This cluster hosts the Keycloak and long-term metrics databases, so:

  • Authentication to ARTESCA (Keycloak) is no longer available.

  • Long-term metrics are no longer stored.

Relevant Alerts

  • KubePersistentVolumeFillingUp:

    The PersistentVolume claimed by pgdata-artesca-postgres-X in Namespace
    artesca-auth is expected to fill up within four days. Currently X% is
    available.
    
  • VolumeDegraded and ClusterDegraded on the same volume.

  • PostgreSQLReplicationLag and PostgreSQLReplicationLagBytes for the lagging replica. They usually fire before the volume fills up.

  • PostgreSQLDown and PostgreSQLExporterError can fire at the same time.

Root Cause

On multi-node deployments, PostgreSQL runs as a three-member cluster managed by Patroni: one leader and two replicas. If a replica is down while a failover happens (node down, pod not scheduled, crash loop), it may come back on an old timeline and fail to catch up with the new leader. The replica does not recover on its own.

While the replica lags behind, its replication slot on the leader keeps the write-ahead log (WAL) from the point where the replica stopped. The replica cannot use this WAL, because it asks for segments of its old timeline that are already gone, so the WAL grows without limit and fills the PostgreSQL volumes.

Note

The alert usually fires for the volume of the leader, not for the volume of the lagging replica. For example, if artesca-postgres-2 lags, the alert can fire for pgdata-artesca-postgres-0. Always check the cluster topology to find the lagging replica.

Extending the volume only delays the issue. The alert comes back until the lagging replica is reinitialized.

Investigation Steps

Note

On a single-node deployment, PostgreSQL has no replica and this procedure does not apply. If the volume fills up, extend it with the Resize Service Volumes procedure and contact Scality support.

Run the following commands from a control plane node.

  1. Identify the affected volume(s) and node(s).

    [artesca-os@bootstrap ~]$
    
    sudo kubectl --kubeconfig=/etc/kubernetes/admin.conf get pvc \
        --namespace artesca-auth
    
    NAME                        STATUS   VOLUME                                CAPACITY   ACCESS MODES   STORAGECLASS
    pgdata-artesca-postgres-0   Bound    keycloak-postgresql-artesca-node-2    10Gi       RWO            ssd-ext4
    pgdata-artesca-postgres-1   Bound    keycloak-postgresql-artesca-node-3    10Gi       RWO            ssd-ext4
    pgdata-artesca-postgres-2   Bound    keycloak-postgresql-artesca-node-1    10Gi       RWO            ssd-ext4
    

    The VOLUME column gives the ARTESCA volume name. The node name is the suffix of the volume name.

  2. Check the usage of each PostgreSQL volume.

    [artesca-os@bootstrap ~]$
    
    for i in 0 1 2; do
      echo "== artesca-postgres-$i"
      sudo kubectl --kubeconfig=/etc/kubernetes/admin.conf exec \
          --namespace artesca-auth artesca-postgres-$i -c postgres -- \
          df -h /home/postgres/pgdata | tail -1
    done
    
    == artesca-postgres-0
    /dev/mapper/vgartesca-keycloak--postgresql--artesca--node--2  9.8G  1.8G  8.1G  18% /home/postgres/pgdata
    == artesca-postgres-1
    /dev/mapper/vgartesca-keycloak--postgresql--artesca--node--3  9.8G  1.4G  8.4G  14% /home/postgres/pgdata
    == artesca-postgres-2
    /dev/mapper/vgartesca-keycloak--postgresql--artesca--node--1  9.8G  281M  9.5G   3% /home/postgres/pgdata
    

    In this example, the volume of the leader (artesca-postgres-0) grows, while the volume of the lagging replica (artesca-postgres-2) does not.

    If a member cannot run the command, look for No space left on device in its PostgreSQL logs. PostgreSQL logs are in the logs container, Patroni logs are in the postgres container:

    [artesca-os@bootstrap ~]$
    
    sudo kubectl --kubeconfig=/etc/kubernetes/admin.conf logs \
        --namespace artesca-auth artesca-postgres-X -c logs --tail=100
    
  3. Check the PostgreSQL cluster topology.

    [artesca-os@bootstrap ~]$
    
    sudo kubectl --kubeconfig=/etc/kubernetes/admin.conf exec \
        --namespace artesca-auth artesca-postgres-0 -c postgres -- \
        patronictl topology
    
    + Cluster: artesca-postgres (7628927643038990395) -------+----+-----------+
    | Member               | Host           | Role         | State     | TL | Lag in MB |
    +----------------------+----------------+--------------+-----------+----+-----------+
    | artesca-postgres-0   | 10.233.109.140 | Leader       | running   | 12 |           |
    | + artesca-postgres-1 | 10.233.204.144 | Sync Standby | streaming | 12 |         0 |
    | + artesca-postgres-2 | 10.233.172.188 | Replica      | running   | 10 |      2404 |
    +----------------------+----------------+--------------+-----------+----+-----------+
    

    Tip

    If artesca-postgres-0 does not answer, run the command in another member.

    A member on a lower timeline (TL) than the leader, with a growing Lag in MB, is a lagging replica. In the example above, artesca-postgres-0 is the leader and artesca-postgres-2 is the lagging replica. The timeline gap and the lag can be large, for example a replica still on TL 1 while the leader is on TL 36, with a lag of several hundred GB.

    Note

    If the patronictl topology output ends with Maintenance mode: on, Patroni is paused. A paused Patroni does not restart PostgreSQL and does not fail over to a replica. Resume it before reinitializing the replica, as described in the resolution steps.

    Important

    If no member has the Leader role, do not continue with this procedure and contact Scality support.

  4. Check the PostgreSQL logs of the lagging replica.

    [artesca-os@bootstrap ~]$
    
    sudo kubectl --kubeconfig=/etc/kubernetes/admin.conf logs \
        --namespace artesca-auth artesca-postgres-2 -c logs --tail=100 \
        | grep "requested WAL segment"
    

    The logs repeat the following error every few seconds:

    2026-10-28 09:39:49 UTC [86]: [2-1] 6ae1c2e5.56 0     FATAL:  could not receive data from WAL stream: ERROR:  requested WAL segment 0000000A00000000000000C1 has already been removed
    2026-10-28 09:39:54 UTC [88]: [2-1] 6ae1c2ea.58 0     FATAL:  could not receive data from WAL stream: ERROR:  requested WAL segment 0000000A00000000000000C1 has already been removed
    

Problem Resolution

Note

The examples below use artesca-postgres-0 as the leader and artesca-postgres-2 as the lagging replica. Replace them with the members identified in the topology.

Important

  • Never reinitialize the leader.

  • Do not delete files in the pg_wal directory by hand.

  • Do not run patronictl remove.

  1. If one or several PostgreSQL volumes are at 100% usage, extend them first.

    Follow the Resize Service Volumes procedure with VOLUME_NAME='keycloak-postgresql-artesca-node-2' and LV_EXPANSION_SIZE="5G". This procedure extends the volume on all nodes.

    Each PostgreSQL volume is a Logical Volume (LV) named keycloak-postgresql-<node> in the vgartesca Volume Group (VG). For example, on artesca-node-2:

    • LV: /dev/vgartesca/keycloak-postgresql-artesca-node-2

    • Device shown by df: /dev/mapper/vgartesca-keycloak--postgresql--artesca--node--2 (each dash of the LV name is doubled)

  2. If Patroni is paused (Maintenance mode: on), resume it.

    A paused Patroni does not start a stopped PostgreSQL and does not fail over to a replica. Resume it even if no volume was full.

    [artesca-os@bootstrap ~]$
    
    sudo kubectl --kubeconfig=/etc/kubernetes/admin.conf exec \
        --namespace artesca-auth artesca-postgres-0 -c postgres -- \
        patronictl resume --wait
    
  3. Wait for the leader to be in the running state in the topology before going to the next step.

  4. Reinitialize the lagging replica from the leader.

    The replica data is deleted and copied again from the leader. The leader, Keycloak and the ARTESCA UI stay available.

    [artesca-os@bootstrap ~]$
    
    sudo kubectl --kubeconfig=/etc/kubernetes/admin.conf exec \
        --namespace artesca-auth artesca-postgres-0 -c postgres -- \
        patronictl reinit artesca-postgres artesca-postgres-2 --force --wait
    
    + Cluster: artesca-postgres (7628927643038990395) ---+-----------+----+-----------+
    | Member             | Host           | Role         | State     | TL | Lag in MB |
    +--------------------+----------------+--------------+-----------+----+-----------+
    | artesca-postgres-0 | 10.233.109.140 | Leader       | running   | 12 |           |
    | artesca-postgres-1 | 10.233.204.144 | Sync Standby | streaming | 12 |         0 |
    | artesca-postgres-2 | 10.233.172.188 | Replica      | running   | 10 |      2404 |
    +--------------------+----------------+--------------+-----------+----+-----------+
    Success: reinitialize for member artesca-postgres-2
    Waiting for reinitialize to complete on: artesca-postgres-2
    Reinitialize is completed on: artesca-postgres-2
    

    The member goes through the creating replica state, then streaming. This takes from a few seconds to a few minutes, depending on the database size.

    If the reinitialization does not start, delete the lagging replica pod, wait for it to be Running, and run the command again:

    [artesca-os@bootstrap ~]$
    
    sudo kubectl --kubeconfig=/etc/kubernetes/admin.conf delete pod \
        --namespace artesca-auth artesca-postgres-2
    

    If two replicas are lagging, reinitialize them one at a time.

  5. Check that all members are on the leader’s timeline, with no lag.

    [artesca-os@bootstrap ~]$
    
    sudo kubectl --kubeconfig=/etc/kubernetes/admin.conf exec \
        --namespace artesca-auth artesca-postgres-0 -c postgres -- \
        patronictl topology
    
    + Cluster: artesca-postgres (7628927643038990395) -------+----+-----------+
    | Member               | Host           | Role         | State     | TL | Lag in MB |
    +----------------------+----------------+--------------+-----------+----+-----------+
    | artesca-postgres-0   | 10.233.109.140 | Leader       | running   | 12 |           |
    | + artesca-postgres-1 | 10.233.204.144 | Sync Standby | streaming | 12 |         0 |
    | + artesca-postgres-2 | 10.233.172.188 | Replica      | streaming | 12 |         0 |
    +----------------------+----------------+--------------+-----------+----+-----------+
    

    Once the replica streams from the leader, its replication slot moves forward and the leader releases the WAL it kept. The volume usage drops and the KubePersistentVolumeFillingUp alert clears within 5 to 10 minutes.

If the reinitialization fails twice, or if the same member lags again, gather the logs and contact Scality support.