Repository navigation
Open
Labels
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.22.0
What version of Kubernetes are you using?
1.27
What is your Kubernetes environment?
Cloud: Amazon EKS
How did you install the operator?
Helm
What happened?
We deployed the operator using a Helm chart and the PostgreSQL cluster resource using a separate Helm chart. Three instances of PostgreSQL were deployed on EC2 Spot instances. After a few hours, it appears that the primary instance (postgres-1) did not gracefully shut down, leading to the absence of the relevant Write-Ahead Logging (WAL) file.
Subsequently, attempts to use pg_rewind have failed, with the process encountering an empty file. Additionally, the file "pg_xact/0000" is also empty, contributing to the inability to resolve the issue and leaving the old primary instance in a stuck state.
Cluster resource
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
annotations:
meta.helm.sh/release-name: postgres-cn
meta.helm.sh/release-namespace: stg
creationTimestamp: "2024-01-09T12:06:49Z"
generation: 4
labels:
app.kubernetes.io/managed-by: Helm
name: postgres
namespace: stg
resourceVersion: "346234286"
uid: 69ddea55-1c72-4e9f-abf6-aa2e43a32db4
spec:
affinity:
podAntiAffinityType: preferred
bootstrap:
initdb:
database: app
encoding: UTF8
import:
databases:
- webapi
source:
externalCluster: xxxxxx
type: microservice
localeCType: C
localeCollate: C
owner: app
enableSuperuserAccess: true
externalClusters:
- connectionParameters:
dbname: webapi
host: xxxxxxxxxxxx
user: postgres
name: xxxxxxx
password:
key: postgres-password
name: xxxxxxxxxxxxxx
failoverDelay: 0
imageName: xxxxxxx/postgresql:16.1-xxxxxxxxx
inheritedMetadata:
labels:
app.kubernetes.io/name: postgres
app.kubernetes.io/version: "16.1"
instances: 3
logLevel: info
maxSyncReplicas: 2
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
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_receiver_timeout: 5s
wal_sender_timeout: 5s
syncReplicaElectionConstraint:
enabled: false
primaryUpdateMethod: restart
primaryUpdateStrategy: unsupervised
replicationSlots:
highAvailability:
enabled: true
slotPrefix: _cnpg_
updateInterval: 30
resources: {}
smartShutdownTimeout: 180
startDelay: 3600
stopDelay: 1800
storage:
resizeInUseVolumes: true
size: 30Gi
storageClass: gp3
superuserSecret:
name: postgres-superuser
switchoverDelay: 3600
status:
certificates:
clientCASecret: postgres-ca
expirations:
postgres-ca: 2024-04-08 12:01:49 +0000 UTC
postgres-replication: 2024-04-08 12:01:49 +0000 UTC
postgres-server: 2024-04-08 12:01:49 +0000 UTC
replicationTLSSecret: postgres-replication
serverAltDNSNames:
- postgres-rw
- postgres-rw.stg
- postgres-rw.stg.svc
- postgres-r
- postgres-r.stg
- postgres-r.stg.svc
- postgres-ro
- postgres-ro.stg
- postgres-ro.stg.svc
serverCASecret: postgres-ca
serverTLSSecret: postgres-server
cloudNativePGCommitHash: 86b9dc80
cloudNativePGOperatorHash: 411a67468c5e1357d387221ce5b11d906bd33d62324846a8c776d206b6c94162
conditions:
- lastTransitionTime: "2024-01-10T08:20:16Z"
message: Cluster Is Not Ready
reason: ClusterIsNotReady
status: "False"
type: Ready
- lastTransitionTime: "2024-01-10T12:18:14Z"
message: Continuous archiving is working
reason: ContinuousArchivingSuccess
status: "True"
type: ContinuousArchiving
configMapResourceVersion:
metrics:
cnpg-default-monitoring: "345484626"
currentPrimary: postgres-2
currentPrimaryTimestamp: "2024-01-10T08:21:59.663283Z"
healthyPVC:
- postgres-1
- postgres-2
- postgres-3
instanceNames:
- postgres-1
- postgres-2
- postgres-3
instances: 3
instancesReportedState:
postgres-1:
isPrimary: false
postgres-2:
isPrimary: true
timeLineID: 2
postgres-3:
isPrimary: false
timeLineID: 2
instancesStatus:
healthy:
- postgres-2
- postgres-3
replicating:
- postgres-1
latestGeneratedNode: 3
managedRolesStatus: {}
phase: Waiting for the instances to become active
phaseReason: Some instances are not yet active. Please wait.
poolerIntegrations:
pgBouncerIntegration: {}
pvcCount: 3
readService: postgres-r
readyInstances: 2
secretsResourceVersion:
applicationSecretVersion: "345484596"
clientCaSecretVersion: "345484593"
externalClusterSecretVersion:
stg-postgres-postgresql: "231319709"
replicationSecretVersion: "345484595"
serverCaSecretVersion: "345484593"
serverSecretVersion: "345484594"
superuserSecretVersion: "341642273"
targetPrimary: postgres-2
targetPrimaryTimestamp: "2024-01-10T08:20:16.701057Z"
timelineID: 2
topology:
instances:
postgres-1: {}
postgres-2: {}
postgres-3: {}
nodesUsed: 2
successfullyExtracted: true
writeService: postgres-rwRelevant log output
{"level":"error","ts":"2024-01-10T10:58:19Z","msg":"Reconciler error","controller":"cluster","controllerGroup":"postgresql.cnpg.io","controllerKind":"Cluster","Cluster":{"name":"postgres","namespace":"stg"},"namespace":"stg","name":"postgres","reconcileID":"9b64cee9-7e71-4e05-9bb0-e1cbaee76c9d","error":"while activating instance: error starting PostgreSQL instance: exit status 1","stacktrace":"sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\tpkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:329\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\tpkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\tpkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:227"}
{"level":"info","ts":"2024-01-10T10:58:28Z","msg":"Cluster status","controller":"cluster","controllerGroup":"postgresql.cnpg.io","controllerKind":"Cluster","Cluster":{"name":"postgres","namespace":"stg"},"namespace":"stg","name":"postgres","reconcileID":"b6dbc5ac-aab1-4528-bc0c-f67aa8dac9b1","uuid":"2f587c83-afa7-11ee-9aef-929973a308f2","logging_pod":"postgres-1","currentPrimary":"postgres-2","targetPrimary":"postgres-2"}
{"level":"info","ts":"2024-01-10T10:58:28Z","msg":"This is an old primary instance, waiting for the switchover to finish","controller":"cluster","controllerGroup":"postgresql.cnpg.io","controllerKind":"Cluster","Cluster":{"name":"postgres","namespace":"stg"},"namespace":"stg","name":"postgres","reconcileID":"b6dbc5ac-aab1-4528-bc0c-f67aa8dac9b1","uuid":"2f587c83-afa7-11ee-9aef-929973a308f2","logging_pod":"postgres-1","currentPrimary":"postgres-2","targetPrimary":"postgres-2"}
{"level":"info","ts":"2024-01-10T10:58:28Z","msg":"Switchover completed","controller":"cluster","controllerGroup":"postgresql.cnpg.io","controllerKind":"Cluster","Cluster":{"name":"postgres","namespace":"stg"},"namespace":"stg","name":"postgres","reconcileID":"b6dbc5ac-aab1-4528-bc0c-f67aa8dac9b1","uuid":"2f587c83-afa7-11ee-9aef-929973a308f2","logging_pod":"postgres-1","targetPrimary":"postgres-2","currentPrimary":"postgres-2"}
{"level":"info","ts":"2024-01-10T10:58:28Z","msg":"Waiting for the new primary to be available","logging_pod":"postgres-1","primaryConnInfo":"host=postgres-rw user=streaming_replica port=5432 sslkey=/controller/certificates/streaming_replica.key sslcert=/controller/certificates/streaming_replica.crt sslrootcert=/controller/certificates/server-ca.crt application_name=postgres-1 sslmode=verify-ca dbname=postgres connect_timeout=5"}
{"level":"info","ts":"2024-01-10T10:58:28Z","msg":"Extracting pg_controldata information","controller":"cluster","controllerGroup":"postgresql.cnpg.io","controllerKind":"Cluster","Cluster":{"name":"postgres","namespace":"stg"},"namespace":"stg","name":"postgres","reconcileID":"b6dbc5ac-aab1-4528-bc0c-f67aa8dac9b1","uuid":"2f587c83-afa7-11ee-9aef-929973a308f2","logging_pod":"postgres-1","reason":"before pg_rewind"}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"pg_controldata","msg":"pg_control version number: 1300\nCatalog version number: 202307071\nDatabase system identifier: 7322068936411099156\nDatabase cluster state: shut down\npg_control last modified: Wed 10 Jan 2024 08:19:35 AM UTC\nLatest checkpoint location: 2/AA000028\nLatest checkpoint's REDO location: 2/AA000028\nLatest checkpoint's REDO WAL file: 0000000100000002000000AA\nLatest checkpoint's TimeLineID: 1\nLatest checkpoint's PrevTimeLineID: 1\nLatest checkpoint's full_page_writes: on\nLatest checkpoint's NextXID: 0:36923\nLatest checkpoint's NextOID: 25092\nLatest checkpoint's NextMultiXactId: 1\nLatest checkpoint's NextMultiOffset: 0\nLatest checkpoint's oldestXID: 722\nLatest checkpoint's oldestXID's DB: 1\nLatest checkpoint's oldestActiveXID: 0\nLatest checkpoint's oldestMultiXid: 1\nLatest checkpoint's oldestMulti's DB: 1\nLatest checkpoint's oldestCommitTsXid:0\nLatest checkpoint's newestCommitTsXid:0\nTime of latest checkpoint: Wed 10 Jan 2024 08:19:35 AM UTC\nFake LSN counter for unlogged rels: 0/3E8\nMinimum recovery ending location: 0/0\nMin recovery ending loc's timeline: 0\nBackup start location: 0/0\nBackup end location: 0/0\nEnd-of-backup record required: no\nwal_level setting: logical\nwal_log_hints setting: on\nmax_connections setting: 100\nmax_worker_processes setting: 32\nmax_wal_senders setting: 10\nmax_prepared_xacts setting: 0\nmax_locks_per_xact setting: 64\ntrack_commit_timestamp setting: off\nMaximum data alignment: 8\nDatabase block size: 8192\nBlocks per segment of large relation: 131072\nWAL block size: 8192\nBytes per WAL segment: 16777216\nMaximum length of identifiers: 64\nMaximum columns in an index: 32\nMaximum size of a TOAST chunk: 1996\nSize of a large-object chunk: 2048\nDate/time type storage: 64-bit integers\nFloat8 argument passing: by value\nData page checksum version: 0\nMock authentication nonce: 4e9ac5de19e20369e90184039bdcf5c867fa08bd811982f2edb29d1f11d8fd7b\n","pipe":"stdout","logging_pod":"postgres-1"}
{"level":"info","ts":"2024-01-10T10:58:28Z","msg":"Starting up pg_rewind","controller":"cluster","controllerGroup":"postgresql.cnpg.io","controllerKind":"Cluster","Cluster":{"name":"postgres","namespace":"stg"},"namespace":"stg","name":"postgres","reconcileID":"b6dbc5ac-aab1-4528-bc0c-f67aa8dac9b1","uuid":"2f587c83-afa7-11ee-9aef-929973a308f2","logging_pod":"postgres-1","pgdata":"/var/lib/postgresql/data/pgdata","options":["-P","--source-server","host=postgres-rw user=streaming_replica port=5432 sslkey=/controller/certificates/streaming_replica.key sslcert=/controller/certificates/streaming_replica.crt sslrootcert=/controller/certificates/server-ca.crt application_name=postgres-1 sslmode=verify-ca dbname=postgres","--target-pgdata","/var/lib/postgresql/data/pgdata","--restore-target-wal"]}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"pg_rewind","msg":"pg_rewind: connected to server","pipe":"stderr","logging_pod":"postgres-1"}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"pg_rewind","msg":"pg_rewind: servers diverged at WAL location 2/A9000860 on timeline 1","pipe":"stderr","logging_pod":"postgres-1"}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"pg_rewind","msg":"pg_rewind: error: could not read file \"/var/lib/postgresql/data/pgdata/pg_wal/0000000100000002000000A8\": read 0 of 8192","pipe":"stderr","logging_pod":"postgres-1"}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"pg_rewind","msg":"pg_rewind: error: could not find previous WAL record at 2/A8241C48","pipe":"stderr","logging_pod":"postgres-1"}
{"level":"error","ts":"2024-01-10T10:58:28Z","msg":"Failed to execute pg_rewind","controller":"cluster","controllerGroup":"postgresql.cnpg.io","controllerKind":"Cluster","Cluster":{"name":"postgres","namespace":"stg"},"namespace":"stg","name":"postgres","reconcileID":"b6dbc5ac-aab1-4528-bc0c-f67aa8dac9b1","uuid":"2f587c83-afa7-11ee-9aef-929973a308f2","logging_pod":"postgres-1","options":["-P","--source-server","host=postgres-rw user=streaming_replica port=5432 sslkey=/controller/certificates/streaming_replica.key sslcert=/controller/certificates/streaming_replica.crt sslrootcert=/controller/certificates/server-ca.crt application_name=postgres-1 sslmode=verify-ca dbname=postgres","--target-pgdata","/var/lib/postgresql/data/pgdata","--restore-target-wal"],"error":"exit status 1","stacktrace":"github.com/cloudnative-pg/cloudnative-pg/pkg/management/log.(*logger).Error\n\tpkg/management/log/log.go:128\ngithub.com/cloudnative-pg/cloudnative-pg/pkg/management/postgres.(*Instance).Rewind\n\tpkg/management/postgres/instance.go:972\ngithub.com/cloudnative-pg/cloudnative-pg/internal/management/controller.(*InstanceReconciler).verifyPgDataCoherenceForPrimary\n\tinternal/management/controller/instance_startup.go:235\ngithub.com/cloudnative-pg/cloudnative-pg/internal/management/controller.(*InstanceReconciler).initialize\n\tinternal/management/controller/instance_controller.go:342\ngithub.com/cloudnative-pg/cloudnative-pg/internal/management/controller.(*InstanceReconciler).Reconcile\n\tinternal/management/controller/instance_controller.go:141\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile\n\tpkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:119\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\tpkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:316\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\tpkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\tpkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:227"}
{"level":"info","ts":"2024-01-10T10:58:28Z","msg":"pg_rewind failed, starting the server to complete the crash recovery","controller":"cluster","controllerGroup":"postgresql.cnpg.io","controllerKind":"Cluster","Cluster":{"name":"postgres","namespace":"stg"},"namespace":"stg","name":"postgres","reconcileID":"b6dbc5ac-aab1-4528-bc0c-f67aa8dac9b1","uuid":"2f587c83-afa7-11ee-9aef-929973a308f2","logging_pod":"postgres-1","err":"error executing pg_rewind: exit status 1"}
{"level":"info","ts":"2024-01-10T10:58:28Z","msg":"Waiting for server to complete crash recovery","logging_pod":"postgres-1"}
{"level":"info","ts":"2024-01-10T10:58:28Z","msg":"Starting up instance","logging_pod":"postgres-1","pgdata":"/var/lib/postgresql/data/pgdata","options":["start","-w","-D","/var/lib/postgresql/data/pgdata","-o","-c port=5432 -c unix_socket_directories=/controller/run","-t 40000000"]}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"pg_ctl","msg":"waiting for server to start....2024-01-10 10:58:28.483 UTC [348] LOG: redirecting log output to logging collector process","pipe":"stdout","logging_pod":"postgres-1"}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"pg_ctl","msg":"2024-01-10 10:58:28.483 UTC [348] HINT: Future log output will appear in directory \"/controller/log\".","pipe":"stdout","logging_pod":"postgres-1"}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"postgres","msg":"2024-01-10 10:58:28.484 UTC [348] LOG: ending log output to stderr","source":"/controller/log/postgres","logging_pod":"postgres-1"}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"postgres","msg":"2024-01-10 10:58:28.484 UTC [348] HINT: Future log output will go to log destination \"csvlog\".","source":"/controller/log/postgres","logging_pod":"postgres-1"}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"postgres","msg":"record","logging_pod":"postgres-1","record":{"log_time":"2024-01-10 10:58:28.484 UTC","process_id":"348","session_id":"659e7854.15c","session_line_num":"1","session_start_time":"2024-01-10 10:58:28 UTC","transaction_id":"0","error_severity":"LOG","sql_state_code":"00000","message":"ending log output to stderr","hint":"Future log output will go to log destination \"csvlog\".","backend_type":"postmaster","query_id":"0"}}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"postgres","msg":"record","logging_pod":"postgres-1","record":{"log_time":"2024-01-10 10:58:28.484 UTC","process_id":"348","session_id":"659e7854.15c","session_line_num":"2","session_start_time":"2024-01-10 10:58:28 UTC","transaction_id":"0","error_severity":"LOG","sql_state_code":"00000","message":"starting PostgreSQL 16.1 (Debian 16.1-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit","backend_type":"postmaster","query_id":"0"}}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"postgres","msg":"record","logging_pod":"postgres-1","record":{"log_time":"2024-01-10 10:58:28.484 UTC","process_id":"348","session_id":"659e7854.15c","session_line_num":"3","session_start_time":"2024-01-10 10:58:28 UTC","transaction_id":"0","error_severity":"LOG","sql_state_code":"00000","message":"listening on IPv4 address \"0.0.0.0\", port 5432","backend_type":"postmaster","query_id":"0"}}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"postgres","msg":"record","logging_pod":"postgres-1","record":{"log_time":"2024-01-10 10:58:28.484 UTC","process_id":"348","session_id":"659e7854.15c","session_line_num":"4","session_start_time":"2024-01-10 10:58:28 UTC","transaction_id":"0","error_severity":"LOG","sql_state_code":"00000","message":"listening on IPv6 address \"::\", port 5432","backend_type":"postmaster","query_id":"0"}}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"postgres","msg":"record","logging_pod":"postgres-1","record":{"log_time":"2024-01-10 10:58:28.488 UTC","process_id":"348","session_id":"659e7854.15c","session_line_num":"5","session_start_time":"2024-01-10 10:58:28 UTC","transaction_id":"0","error_severity":"LOG","sql_state_code":"00000","message":"listening on Unix socket \"/controller/run/.s.PGSQL.5432\"","backend_type":"postmaster","query_id":"0"}}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"postgres","msg":"record","logging_pod":"postgres-1","record":{"log_time":"2024-01-10 10:58:28.495 UTC","process_id":"352","session_id":"659e7854.160","session_line_num":"1","session_start_time":"2024-01-10 10:58:28 UTC","transaction_id":"0","error_severity":"LOG","sql_state_code":"00000","message":"database system was shut down at 2024-01-10 08:19:35 UTC","backend_type":"startup","query_id":"0"}}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"postgres","msg":"record","logging_pod":"postgres-1","record":{"log_time":"2024-01-10 10:58:28.495 UTC","process_id":"352","session_id":"659e7854.160","session_line_num":"2","session_start_time":"2024-01-10 10:58:28 UTC","transaction_id":"0","error_severity":"FATAL","sql_state_code":"XX000","message":"could not access status of transaction 36923","detail":"Could not read from file \"pg_xact/0000\" at offset 8192: read too few bytes.","backend_type":"startup","query_id":"0"}}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"postgres","msg":"record","logging_pod":"postgres-1","record":{"log_time":"2024-01-10 10:58:28.496 UTC","process_id":"348","session_id":"659e7854.15c","session_line_num":"6","session_start_time":"2024-01-10 10:58:28 UTC","transaction_id":"0","error_severity":"LOG","sql_state_code":"00000","message":"startup process (PID 352) exited with exit code 1","backend_type":"postmaster","query_id":"0"}}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"postgres","msg":"record","logging_pod":"postgres-1","record":{"log_time":"2024-01-10 10:58:28.497 UTC","process_id":"348","session_id":"659e7854.15c","session_line_num":"7","session_start_time":"2024-01-10 10:58:28 UTC","transaction_id":"0","error_severity":"LOG","sql_state_code":"00000","message":"aborting startup due to startup process failure","backend_type":"postmaster","query_id":"0"}}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"postgres","msg":"record","logging_pod":"postgres-1","record":{"log_time":"2024-01-10 10:58:28.497 UTC","process_id":"348","session_id":"659e7854.15c","session_line_num":"8","session_start_time":"2024-01-10 10:58:28 UTC","transaction_id":"0","error_severity":"LOG","sql_state_code":"00000","message":"database system is shut down","backend_type":"postmaster","query_id":"0"}}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"pg_ctl","msg":" stopped waiting","pipe":"stdout","logging_pod":"postgres-1"}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"pg_ctl","msg":"pg_ctl: could not start server","pipe":"stderr","logging_pod":"postgres-1"}
{"level":"info","ts":"2024-01-10T10:58:28Z","logger":"pg_ctl","msg":"Examine the log output.","pipe":"stderr","logging_pod":"postgres-1"}
{"level":"info","ts":"2024-01-10T10:58:28Z","msg":"Exited log pipe","fileName":"/controller/log/postgres.csv","logging_pod":"postgres-1"}
{"level":"error","ts":"2024-01-10T10:58:28Z","msg":"Reconciler error","controller":"cluster","controllerGroup":"postgresql.cnpg.io","controllerKind":"Cluster","Cluster":{"name":"postgres","namespace":"stg"},"namespace":"stg","name":"postgres","reconcileID":"b6dbc5ac-aab1-4528-bc0c-f67aa8dac9b1","error":"while activating instance: error starting PostgreSQL instance: exit status 1","stacktrace":"sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\tpkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:329\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\tpkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\tpkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:227"}Code of Conduct
- I agree to follow this project's Code of Conduct
Reacted by Suleimi Akarasu Ahmed, Janos Miko, weberc2, Nepoxx, Andrew Davies, serhii-elisity, Ferenc Tamás, Gabe Cook, Raz, Vahid Alimohamadi and 41 more
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
gbartolini commentedon Jan 11, 2024
From what I can see, it looks like an issue with the underlying file system (data corruption of that file). You need to recreate the PVC of that instance.
orenzah commentedon Jan 11, 2024
It happens 2 days in a row, we are using EC2 spot instances, and we managed to solve it by deleting the problematic PVC (gp3) but that manual PVC creation every day is probably not the desired behavior.
gbartolini commentedon Jan 17, 2024
This might be related to #3698. Give us some time to investigate.
janosmiko commentedon Feb 29, 2024
I face the same issue in multiple clusters in the same k8s cluster. I think it occurs when a network error happens.
The only way to resolve it is to delete the PVC of the failing pod and remove the pod. In this case, the operator is going to recreate the failing replica.
Logs:
movergan commentedon Apr 1, 2024
Just encountered into the same issue in GKE
suleimi commentedon Apr 20, 2024
I keep running into this every other day
maaft commentedon Apr 22, 2024
Also discovered this now.. is CNPG team aware of this? Whom to ping about this issue?
only working solution was to delete the failing Pod and PVC so a new node is created to join the cluster
oberai07 commentedon Apr 26, 2024
I am facing similar issue. Do we have any fix available for below issue ? I tried to delete the pod but did not help.
{"level":"error","ts":"2024-02-29T07:12:33Z","msg":"PostgreSQL process exited with errors","logging_pod":"harbor-postgres-3","error":"exit status 1","stacktrace":"github.com/cloudnative-pg/cloudnative-pg/pkg/management/log.(*logger).Error\n\tpkg/management/log/log.go:128\ngithub.com/cloudnative-pg/cloudnative-pg/internal/cmd/manager/instance/run/lifecycle.(*PostgresLifecycle).Start\n\tinternal/cmd/manager/instance/run/lifecycle/lifecycle.go:98\nsigs.k8s.io/controller-runtime/pkg/manager.(*runnableGroup).reconcile.func1\n\tpkg/mod/sigs.k8s.io/[email protected]/pkg/manager/runnable_group.go:223"}janosmiko commentedon Apr 26, 2024
@gbartolini is it possible to modify the health check behavior of the pods managed by CNPG?
suleimi commentedon Apr 26, 2024
@gbartolini Any updates on this would be greatly appreciated 🙏🏿
brettinternet commentedon Jun 7, 2024
The only way I've been able to recover from this is to delete both the PVC and Pod
Dev-Destructor commentedon Jul 5, 2024
Same Issue here. Luckily, Our production cluster survived because one of the 3 replicas was working. Deleting both PVC and Pod solved the issue but it is not a permanent solution.
we use GKE
33 remaining items
darkpixel commentedon Feb 5, 2026
Stale bots are dumb.
It's not stale because it's waiting on users, it's stale because the issue hasn't been fixed yet. ;)
Brice187 commentedon Feb 19, 2026
still happens on
dosubot commentedon May 22, 2026
Hi, @orenzah. I'm Dosu, and I'm helping the cloudnative-pg team manage their backlog and am marking this issue as stale.
Issue Summary
pg_rewindor PostgreSQL startup to fail, leaving the pod stuck and preventing automatic cluster recovery.Next Steps
Thanks for your understanding and contribution.
davidpanic commentedon May 25, 2026
Stale bots suck. This is still an issue.
github-actions commentedon Sep 4, 2026
This issue is stale because it has been open for 60 days with no activity.
amalic commentedon Sep 4, 2026
This issue needs a solution, otherwise CNPG cannot be used in production!
WoahitsJoe commentedon Oct 26, 2026
We weren’t able to reproduce this with CNPG 1.30.1 and PostgreSQL 18.6 on GKE 1.35.8, using two PostgreSQL instances on Spot VMs, synchronous replication, and Persistent Disk CSI storage.
We tested three simulated Spot preemptions and two abrupt resets of the primary VM, including tests at approximately 300 committed transactions/second across eight connections.
Both abrupt resets produced confirmed unclean PostgreSQL shutdowns. Crash recovery and pg_rewind completed successfully, and the old primary rejoined using its original PVC without manual intervention. We observed none of the reported missing/empty WAL errors.
darkpixel commentedon Oct 26, 2026
I have a hunch that people here are using "Longhorn" for storage.
A few weeks back, I decided to throw Claude at it on a test cluster. It said that one instance would basically "fork" from the other instances due to Longhorn not supporting fsync combined with the number of disk replicas. So if you had a 3-instance cluster and each instance had (for example) 3 disk instances, CNPG would be chugging along like normal sending fsync's...then a node containing an instance might suddenly go offline...and the remaining instances think it has a certain set of data (based off the faked fsync response)...then when the node comes back online or the cluster shuffles the dead instance to a new node (and maybe uses one of its other disk replicas) the data isn't consistent and it causes a "fork".
When this happens I can confirm blowing away the underlying disk and instance of the "forked" CNPG pod and allowing CNPG to create a new one and joining it to the cluster.