Repository navigation
Description
What happened
Removing a replication-sensitive parameter (e.g. max_connections) from spec.postgresql.parameters causes replicas that need WAL replay to enter CrashLoopBackOff with:
FATAL: recovery aborted because of insufficient parameter settings
DETAIL: max_connections = 100 is a lower setting than on the primary server, where its value was 200.
How to reproduce
- Create a 3-instance Cluster with
max_connections: "200"inspec.postgresql.parameters. - Wait for all instances to be healthy.
- Remove
max_connectionsfrom the spec (or remove theparametersmap entirely). - The operator updates
custom.confon all instances, removing themax_connectionsline. Running instances keep 200 (restart-required param). - Trigger a failover. The new primary restarts and picks up the PG default of 100.
- A replica whose last checkpoint was written with
max_connections=200inpg_controldatatries to start with 100 → FATAL → CrashLoopBackOff.
Root cause
The safety mechanism in verifyParametersForFollower is designed to catch exactly this kind of mismatch, but it silently skips parameters that are absent from the Cluster spec.
LoadEnforcedParametersFromCluster (pkg/management/postgres/restore.go:785):
for _, param := range pgControldataSettingsToParamsMap {
value, found := clusterParams[param]
if !found {
continue // param removed from spec → not returned at all
}
// ...
}verifyParametersForFollower (internal/management/controller/instance_controller.go:557):
for key, enforcedparam := range controldataParams {
clusterparam, found := clusterParams[key]
if !found {
continue // pg_controldata says 200, spec says nothing → skip the safety check
}
if enforcedparam > clusterparam {
options[key] = strconv.Itoa(enforcedparam)
}
}When a parameter is present in pg_controldata (e.g. max_connections = 200) but absent from the Cluster spec, the !found branch skips it. The safety write to custom.conf never happens, and PostgreSQL crashes during recovery.
Proposed fix
When a replication-sensitive parameter is absent from the Cluster spec, LoadEnforcedParametersFromCluster (or verifyParametersForFollower directly) should fall back to the PostgreSQL default value for that parameter instead of skipping it.
For example, in verifyParametersForFollower:
for key, enforcedparam := range controldataParams {
clusterparam, found := clusterParams[key]
if !found {
clusterparam = postgresDefaultFor(key) // e.g. 100 for max_connections
}
if enforcedparam > clusterparam {
options[key] = strconv.Itoa(enforcedparam)
}
}This way, if pg_controldata records max_connections = 200 and the spec doesn't set it (defaulting to 100), the function would write max_connections = 200 into custom.conf before starting PostgreSQL — preventing the crash.
Environment
- CNPG operator: 1.28.0 (also verified the code is identical on current main)
- PostgreSQL: 16
- Kubernetes: EKS
Activity
gmautner commentedon Mar 31, 2026
Duplicate — re-filed using the repository's bug report form.