Repository navigation
Closed
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.30.0
What version of Kubernetes are you using?
1.36
What is your Kubernetes environment?
Self-managed: kind (evaluation)
How did you install the operator?
YAML manifest
What happened?
I have a cluster for immich with 2 instances and it was working fine. But then all of a sudden the second instance is stuck in a loop saying the database system is starting up and I believe it's due to this log could not receive data from WAL stream: ERROR: requested WAL segment 0000000200000001000000C1 has already been removed however I can't seem to figure out why and I don't want to lose the db, I have backed it up with pg_dump on the healthy instance for now.
Please excuse my ignorance if this is a simple fix, I'm pretty new to postgres and don't have much experience with the details of how it works.
Thanks
Cluster resource
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: immich
namespace: media-db
spec:
instances: 2
storage:
size: 3Gi
storageClass: longhorn
imageName: ghcr.io/cloudnative-pg/postgresql:18-standard-trixie
# bootstrap:
# initdb:
# database: immich
# owner: immich
# secret:
# name: immich-pg
# bootstrap:
# initdb:
# import:
# type: microservice
# databases:
# - immich
# source:
# externalCluster: immich-postgres-unraid
# externalClusters:
# - name: immich-postgres-unraid
# connectionParameters:
# host: 10.0.20.176
# user: immich
# dbname: immich
# password:
# name: immich-postgres-unraid-password
# key: password
managed:
roles:
- name: immich
login: true
passwordSecret:
name: immich-pg
postgresql:
shared_preload_libraries:
- "vchord.so"
# This extension is loaded via the Database CRD at cloudnative-pg-database.yaml
extensions:
- name: vchord
image:
reference: ghcr.io/tensorchord/vchord-scratch:pg18-v1.1.1
dynamic_library_path:
- /usr/lib/postgresql/18/lib
extension_control_path:
- /usr/share/postgresql/18/
---
apiVersion: postgresql.cnpg.io/v1
kind: Database
metadata:
name: immich
namespace: media-db
spec:
cluster:
name: immich
name: immich
owner: immich
databaseReclaimPolicy: retain
extensions:
- name: vector
ensure: present
- name: vchord
ensure: present
- name: earthdistance
ensure: present
- name: cube
ensure: presentRelevant log output
{
"level": "info",
"ts": "2026-07-01T23:09:09.070669186Z",
"logger": "postgres",
"msg": "record",
"logging_pod": "immich-2",
"record": {
"log_time": "2026-07-01 23:09:09.070 UTC",
"user_name": "postgres",
"database_name": "postgres",
"process_id": "4559",
"connection_from": "[local]",
"session_id": "6a459e15.11cf",
"session_line_num": "1",
"session_start_time": "2026-07-01 23:09:09 UTC",
"transaction_id": "0",
"error_severity": "FATAL",
"sql_state_code": "57P03",
"message": "the database system is starting up",
"backend_type": "client backend",
"query_id": "0"
}
}
{
"level": "info",
"ts": "2026-07-01T23:09:09.486876268Z",
"logger": "postgres",
"msg": "record",
"logging_pod": "immich-2",
"record": {
"log_time": "2026-07-01 23:09:09.486 UTC",
"process_id": "4575",
"session_id": "6a459e15.11df",
"session_line_num": "1",
"session_start_time": "2026-07-01 23:09:09 UTC",
"transaction_id": "0",
"error_severity": "LOG",
"sql_state_code": "00000",
"message": "started streaming WAL from primary at 1/C1000000 on timeline 2",
"backend_type": "walreceiver",
"query_id": "0"
}
}
{
"level": "info",
"ts": "2026-07-01T23:09:09.487239893Z",
"logger": "postgres",
"msg": "record",
"logging_pod": "immich-2",
"record": {
"log_time": "2026-07-01 23:09:09.486 UTC",
"process_id": "4575",
"session_id": "6a459e15.11df",
"session_line_num": "2",
"session_start_time": "2026-07-01 23:09:09 UTC",
"transaction_id": "0",
"error_severity": "FATAL",
"sql_state_code": "08P01",
"message": "could not receive data from WAL stream: ERROR: requested WAL segment 0000000200000001000000C1 has already been removed",
"backend_type": "walreceiver",
"query_id": "0"
}
}
{
"level": "info",
"ts": "2026-07-01T23:09:09.568854443Z",
"logger": "wal-restore",
"msg": "Refusing to restore future timeline history file",
"logging_pod": "immich-2",
"walName": "00000004.history",
"fileTimeline": 4,
"clusterTimeline": 3
}
{
"level": "info",
"ts": "2026-07-01T23:09:09.704930172Z",
"logger": "postgres",
"msg": "record",
"logging_pod": "immich-2",
"record": {
"log_time": "2026-07-01 23:09:09.697 UTC",
"process_id": "30",
"session_id": "6a459bfb.1e",
"session_line_num": "109",
"session_start_time": "2026-07-01 23:00:11 UTC",
"transaction_id": "0",
"error_severity": "LOG",
"sql_state_code": "00000",
"message": "waiting for WAL to become available at 1/C1002000",
"backend_type": "startup",
"query_id": "0"
}
}
{
"level": "info",
"ts": "2026-07-01T23:09:09.847673325Z",
"logger": "cluster-resource",
"msg": "Defaulting for Cluster",
"version": "v1",
"logging_pod": "immich-2",
"name": "immich",
"namespace": "media-db"
}
{
"level": "info",
"ts": "2026-07-01T23:09:10.033555438Z",
"logger": "postgres",
"msg": "record",
"logging_pod": "immich-2",
"record": {
"log_time": "2026-07-01 23:09:10.033 UTC",
"user_name": "postgres",
"database_name": "postgres",
"process_id": "4584",
"connection_from": "[local]",
"session_id": "6a459e16.11e8",
"session_line_num": "1",
"session_start_time": "2026-07-01 23:09:10 UTC",
"transaction_id": "0",
"error_severity": "FATAL",
"sql_state_code": "57P03",
"message": "the database system is starting up",
"backend_type": "client backend",
"query_id": "0"
}
}
{
"level": "info",
"ts": "2026-07-01T23:09:10.035318803Z",
"msg": "Instance is still down, will retry in 1 second",
"logger": "instance-manager",
"logging_pod": "immich-2",
"controller": "instance-cluster",
"controllerGroup": "postgresql.cnpg.io",
"controllerKind": "Cluster",
"Cluster": {
"name": "immich",
"namespace": "media-db"
},
"namespace": "media-db",
"name": "immich",
"reconcileID": "be86f94c-8e4a-4c43-90ff-c5e58a388e6a",
"instance": "immich-2",
"cluster": "immich"
}
{
"level": "info",
"ts": "2026-07-01T23:09:10.198280271Z",
"logger": "postgres",
"msg": "record",
"logging_pod": "immich-2",
"record": {
"log_time": "2026-07-01 23:09:10.195 UTC",
"user_name": "postgres",
"database_name": "postgres",
"process_id": "4585",
"connection_from": "[local]",
"session_id": "6a459e16.11e9",
"session_line_num": "1",
"session_start_time": "2026-07-01 23:09:10 UTC",
"transaction_id": "0",
"error_severity": "FATAL",
"sql_state_code": "57P03",
"message": "the database system is starting up",
"backend_type": "client backend",
"query_id": "0"
}
}
{
"level": "info",
"ts": "2026-07-01T23:09:10.225999691Z",
"logger": "postgres",
"msg": "record",
"logging_pod": "immich-2",
"record": {
"log_time": "2026-07-01 23:09:10.219 UTC",
"user_name": "postgres",
"database_name": "postgres",
"process_id": "4586",
"connection_from": "[local]",
"session_id": "6a459e16.11ea",
"session_line_num": "1",
"session_start_time": "2026-07-01 23:09:10 UTC",
"transaction_id": "0",
"error_severity": "FATAL",
"sql_state_code": "57P03",
"message": "the database system is starting up",
"backend_type": "client backend",
"query_id": "0"
}
}
{
"level": "info",
"ts": "2026-07-01T23:09:10.284198255Z",
"logger": "postgres",
"msg": "record",
"logging_pod": "immich-2",
"record": {
"log_time": "2026-07-01 23:09:10.282 UTC",
"user_name": "postgres",
"database_name": "postgres",
"process_id": "4587",
"connection_from": "[local]",
"session_id": "6a459e16.11eb",
"session_line_num": "1",
"session_start_time": "2026-07-01 23:09:10 UTC",
"transaction_id": "0",
"error_severity": "FATAL",
"sql_state_code": "57P03",
"message": "the database system is starting up",
"backend_type": "client backend",
"query_id": "0"
}
}
{
"level": "info",
"ts": "2026-07-01T23:09:10.562421362Z",
"logger": "postgres",
"msg": "record",
"logging_pod": "immich-2",
"record": {
"log_time": "2026-07-01 23:09:10.561 UTC",
"user_name": "postgres",
"database_name": "postgres",
"process_id": "4588",
"connection_from": "[local]",
"session_id": "6a459e16.11ec",
"session_line_num": "1",
"session_start_time": "2026-07-01 23:09:10 UTC",
"transaction_id": "0",
"error_severity": "FATAL",
"sql_state_code": "57P03",
"message": "the database system is starting up",
"backend_type": "client backend",
"query_id": "0"
}
}
{
"level": "info",
"ts": "2026-07-01T23:09:11.038195437Z",
"logger": "cluster-resource",
"msg": "Defaulting for Cluster",
"version": "v1",
"logging_pod": "immich-2",
"name": "immich",
"namespace": "media-db"
}
{
"level": "info",
"ts": "2026-07-01T23:09:11.256902745Z",
"logger": "postgres",
"msg": "record",
"logging_pod": "immich-2",
"record": {
"log_time": "2026-07-01 23:09:11.256 UTC",
"user_name": "postgres",
"database_name": "postgres",
"process_id": "4590",
"connection_from": "[local]",
"session_id": "6a459e17.11ee",
"session_line_num": "1",
"session_start_time": "2026-07-01 23:09:11 UTC",
"transaction_id": "0",
"error_severity": "FATAL",
"sql_state_code": "57P03",
"message": "the database system is starting up",
"backend_type": "client backend",
"query_id": "0"
}
}
{
"level": "info",
"ts": "2026-07-01T23:09:11.258517343Z",
"msg": "Instance is still down, will retry in 1 second",
"logger": "instance-manager",
"logging_pod": "immich-2",
"controller": "instance-cluster",
"controllerGroup": "postgresql.cnpg.io",
"controllerKind": "Cluster",
"Cluster": {
"name": "immich",
"namespace": "media-db"
},
"namespace": "media-db",
"name": "immich",
"reconcileID": "bc8859f1-3254-4a89-bfc6-7a4de1e95563",
"instance": "immich-2",
"cluster": "immich"
}
{
"level": "info",
"ts": "2026-07-01T23:09:11.85182318Z",
"logger": "postgres",
"msg": "record",
"logging_pod": "immich-2",
"record": {
"log_time": "2026-07-01 23:09:11.851 UTC",
"user_name": "postgres",
"database_name": "postgres",
"process_id": "4591",
"connection_from": "[local]",
"session_id": "6a459e17.11ef",
"session_line_num": "1",
"session_start_time": "2026-07-01 23:09:11 UTC",
"transaction_id": "0",
"error_severity": "FATAL",
"sql_state_code": "57P03",
"message": "the database system is starting up",
"backend_type": "client backend",
"query_id": "0"
}
}
{
"level": "info",
"ts": "2026-07-01T23:09:12.261574375Z",
"logger": "cluster-resource",
"msg": "Defaulting for Cluster",
"version": "v1",
"logging_pod": "immich-2",
"name": "immich",
"namespace": "media-db"
}
{
"level": "info",
"ts": "2026-07-01T23:09:12.373994348Z",
"logger": "postgres",
"msg": "record",
"logging_pod": "immich-2",
"record": {
"log_time": "2026-07-01 23:09:12.373 UTC",
"user_name": "postgres",
"database_name": "postgres",
"process_id": "4593",
"connection_from": "[local]",
"session_id": "6a459e18.11f1",
"session_line_num": "1",
"session_start_time": "2026-07-01 23:09:12 UTC",
"transaction_id": "0",
"error_severity": "FATAL",
"sql_state_code": "57P03",
"message": "the database system is starting up",
"backend_type": "client backend",
"query_id": "0"
}
}
{
"level": "info",
"ts": "2026-07-01T23:09:12.376692418Z",
"msg": "Instance is still down, will retry in 1 second",
"logger": "instance-manager",
"logging_pod": "immich-2",
"controller": "instance-cluster",
"controllerGroup": "postgresql.cnpg.io",
"controllerKind": "Cluster",
"Cluster": {
"name": "immich",
"namespace": "media-db"
},
"namespace": "media-db",
"name": "immich",
"reconcileID": "5422f86a-e46c-49c5-8dc1-79c394842bbd",
"instance": "immich-2",
"cluster": "immich"Code of Conduct
- I agree to follow this project's Code of Conduct
Reacted by dosubot
Activity
dosubot commentedon Jul 1, 2026
This is a known scenario in CloudNativePG where the replica (
immich-2) has fallen behind and the WAL segments it needs have already been removed from the primary. The replica cannot catch up via streaming replication because the required WAL segment (0000000200000001000000C1) no longer exists on the primary.What's happening: Your replica needs WAL data starting at position
1/C1000000, but the primary has already recycled those segments. Since you don't have WAL archiving configured (no backup/object store), there's no fallback source for those segments — the replica is stuck in a loop trying to stream WAL it can never receive [1].How to fix it: You'll need to manually rebuild the replica. The simplest approach with CloudNativePG is to delete the replica's PVC and let the operator recreate it from scratch via
pg_basebackupfrom the healthy primary [2]:Your primary is fine — data is safe there, and you've already done a
pg_dumpbackup which is great.To help prevent this in the future:
wal_keep_sizeis512MB[3] — if your workload generates more WAL than that before the replica can consume it, you may want to increase it inspec.postgresql.parametersNote: Since your cluster has gone through multiple timelines (the logs show timeline 2 streaming and a reference to timeline 4), it's possible a previous failover/switchover event contributed to this state. The rebuild via PVC deletion should resolve it cleanly.
To reply, just mention @dosu.
Docs are dead. Just use Dosu.
ardentperf commentedon Jul 2, 2026
please make sure you have proper (CNPG) backups too - but great to have a
pg_dumpas well for safetyif your primary is healthy then yes can rebuild the replica pod -- but the
cnpg destroycommand is officially documented and might be a little safer than manually deleting pods & pvcs under operatorhttps://cloudnative-pg.io/docs/1.30/kubectl-plugin#destroy
the more interesting message here is
Refusing to restore future timeline history filewith the timeline 4 file. i wonder what happened to the timeline 3 file. think i saw this mentioned in another issue somewhere recentlyinteresting to note that your seeing this on 1.30 even with the new primary lease in place, which i hope will reduce some of these timeline/failover issues
DizzieNight commentedon Jul 2, 2026
Yeah I need to setup proper WAL Archiving for the future. I do have the pvs backed up via longhorn so that's always a failsafe, however longhorn can be kinda annoying sometimes with backups, I've had them fail multiple times.
I just upgraded recently to 1.30 which was after the immich-2 pod failed.
I'll look into the
cnpg destroycommand, I thought it would delete the backend data too but I could be wrong.Thanks for the help :)