Repository navigation
Description
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
Version
1.27 (latest patch)
What version of Kubernetes are you using?
1.33
What is your Kubernetes environment?
Other
How did you install the operator?
Helm
What happened?
During High Availability testing we intentionally killed a Kubernetes node.
We have 2 Clusters, both with 1 sync replica.
Cluster A failed over correctly, and after restarting the node, the replica come back fine, but the dataset is quite small (< 1GB).
Cluster B, which has a larger dataset (~51GB), failed over correctly, but after we restarted the node, the replica doesn't come online properly. It's trying to rejoin the primary, but is missing WAL files, this results in an infinite loop of the Replica trying to join the new Primary.
When manually destroying the replica, a new replica is built correctly.
We have not configured Replication Slots explicitly, but they are enabled by default by Helm, which should have kept the (new) Primary from deleting the WAL files.
The current WAL keep size is set to the default of 512MB, and I would not expect there to be more than 512MB of changed data in the time we did this test (but the cluster was actively in use).
There might be some mitigations for this issue:
- Manaully increasing the WAL keep size, even though there are Replication Slots active.
- Excplicitly configuring more Replication Slots, but we were under the impression that the Operator managed this for us, as we can see the Replication Slots being in use when viewing the cluster status using
kubectl cnpg status <cluster>.
Anyone know what is happening here?
Cluster resource
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
annotations:
name: dsssor
spec:
affinity:
podAntiAffinityType: preferred
bootstrap:
initdb:
database: irrelevant
encoding: UTF8
localeCType: C
localeCollate: C
owner: sorting-service
postInitApplicationSQL:
# Irrelevant
certificates:
serverCASecret: secret-dsssor-tls
serverTLSSecret: secret-dsssor-tls
description: *snip*
enablePDB: true
enableSuperuserAccess: false
failoverDelay: 0
imageName: ghcr.io/cloudnative-pg/postgresql:17.5
instances: 2
logLevel: info
managed:
roles:
- irrelevant
services: irrelevent
maxSyncReplicas: 1
minSyncReplicas: 1
monitoring:
customQueriesConfigMap:
- key: queries
name: cnpg-default-monitoring
disableDefaultQueries: false
enablePodMonitor: false
postgresGID: 26
postgresUID: 26
postgresql:
parameters:
archive_mode: "on"
archive_timeout: 5min
dynamic_shared_memory_type: posix
full_page_writes: "on"
log_destination: csvlog
log_directory: /controller/log
log_filename: postgres
log_rotation_age: "0"
log_rotation_size: "0"
log_truncate_on_rotation: "false"
logging_collector: "on"
max_parallel_workers: "32"
max_replication_slots: "32"
max_worker_processes: "32"
shared_memory_type: mmap
shared_preload_libraries: ""
ssl_max_protocol_version: TLSv1.3
ssl_min_protocol_version: TLSv1.3
wal_keep_size: 512MB
wal_level: logical
wal_log_hints: "on"
wal_receiver_timeout: 5s
wal_sender_timeout: 5s
pg_hba:
- host all all <pod-cidr> scram-sha-256
- hostnossl all all 0.0.0.0/0 reject
- hostssl all all 0.0.0.0/0 scram-sha-256
syncReplicaElectionConstraint:
enabled: false
primaryUpdateMethod: restart
primaryUpdateStrategy: unsupervised
probes:
liveness:
isolationCheck:
connectionTimeout: 1000
enabled: true
requestTimeout: 1000
replicationSlots:
highAvailability:
enabled: true
slotPrefix: _cnpg_
synchronizeReplicas:
enabled: true
updateInterval: 30
resources:
limits:
cpu: "2"
memory: 8Gi
requests:
cpu: "2"
memory: 8Gi
smartShutdownTimeout: 180
startDelay: 3600
stopDelay: 1800
storage:
resizeInUseVolumes: true
size: 150Gi
storageClass: irrelevant
switchoverDelay: 3600Relevant log output
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
dosubot commentedon Oct 3, 2025
Hi @FireDrunk! I'm Dosu and I’m helping the cloudnative-pg team.
This is a known limitation in CloudNativePG, especially during failover or disruptive events like node restarts. Even with replication slots enabled and managed by the operator, there are scenarios where WAL segments can be deleted before a lagging replica is able to catch up. This typically happens due to timing gaps during failover or when the new primary doesn't immediately have all the necessary replication slots or WAL retention settings, leading to premature WAL removal. The default
wal_keep_size(512MB) may not be sufficient for large or busy clusters, and if a replica is offline or slow to rejoin, the primary may recycle WAL segments needed for recovery, resulting in the infinite rejoin loop you observed. Manual intervention (deleting the replica PVC and letting the operator rebuild it) is a common workaround and is documented in several issues and discussions (example, discussion).To reduce the risk, consider increasing
wal_keep_sizeand explicitly settingmax_slot_wal_keep_size(recommended for PostgreSQL 13+), and ensure you have a backup/archiving strategy in place (docs). Monitoring replication slot lag and WAL retention is also important. This behavior is not unique to your setup and is not fully resolved in the current version (troubleshooting guide).To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
github-actions commentedon Dec 19, 2025
This issue is stale because it has been open for 60 days with no activity.
github-actions commentedon Jan 2, 2026
This issue was closed because it has been inactive for 14 days since being marked as stale.