Repository navigation
Description
Propose changing the default value of .spec.smartShutdownTimeout from 180 to 0 in the upcoming 1.31.0 release, so that new clusters skip the smart shutdown phase and go straight to a fast shutdown (still preceded by a CHECKPOINT) when a Postgres Pod is terminated.
Current behavior
When the instance manager receives SIGTERM, or its context is cancelled, it runs TryShuttingDownSmartFast (pkg/management/postgres/instance.go):
CHECKPOINT, then a smart shutdown, for up tosmartShutdownTimeoutseconds (default 180). A smart shutdown disallows new connections and waits for every existing client to disconnect on its own.- If Postgres is still up, a fast shutdown (preceded by another
CHECKPOINT), which terminates existing connections. It waits up tostopDelay, which is the Pod's termination grace period.
The default is defined in two places:
- the
+kubebuilder:default:=180marker onSmartShutdownTimeout(api/v1/cluster_types.go) - the fallback in
GetSmartShutdownTimeout()(api/v1/cluster_funcs.go)
Problem
In practice the smart phase rarely achieves anything. Applications and connection poolers hold long-lived connections, so Postgres almost never reaches a clean smart shutdown within the window. The result is that the full 180 seconds is spent waiting before the fast shutdown starts. This delays:
- node drains
- rolling updates and restarts of replicas
- any operation that needs a Postgres Pod to terminate
The fast shutdown does the same CHECKPOINT work either way, so skipping the smart phase does not reduce durability.
Proposal
- Set the kubebuilder default to
0and update the field's doc comment. - Change the fallback in
GetSmartShutdownTimeout()to0, and fix its comment (it currently says "positive integer"). - Update
docs/src/instance_manager.md("Shutdown control"), which currently states the default is 180 and describes smart shutdown as step 1. - Regenerate the CRD and API docs (
make generate manifests apidoc). - Add a 1.31.0 release note under Important changes.
- Add tests for the default and for the
0path.
Feasibility
No new code path is needed. TryShuttingDownSmartFast already skips the smart step when smartTimeout == 0, and goes directly to a fast shutdown bounded by stopDelay. This is the same path taken today when stopDelay <= smartShutdownTimeout. The field is a *int32, so an explicit 0 is distinguishable from unset, and there is no webhook validation that would reject it. Users can already set 0 explicitly today.
Compatibility and trade-offs
- Existing clusters are unaffected. The CRD default is persisted in the Cluster spec at admission, so existing clusters already store
smartShutdownTimeout: 180. Only new clusters, and clusters without the field persisted, get the new behavior. Users who want the old behavior can setsmartShutdownTimeout: 180explicitly. - Behavior change for new clusters. Clients no longer get a grace window of up to 3 minutes to finish in-flight transactions. They are disconnected as soon as the Pod is terminated. This is a deliberate trade-off of graceful client draining against faster Pod termination.
- Scope. Switchover and step-down already use a fast shutdown. This only affects the SIGTERM and operator-restart path.
Open questions
- Is
0the right default, or should it be a smaller non-zero value (for example 5 to 15 seconds) to give very short-lived clients a chance to disconnect?
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
mnencia commentedon Nov 17, 2026
I agree,
0is the right default.Most applications today have their own connection pool. Those connections are long-lived, so a smart shutdown almost never completes and we just wait out the full timeout. Meanwhile the instance is unavailable to new connections.
In a cloud native setup the application has to handle connection loss anyway (failover, node loss, crashes). A fast shutdown with a quick recovery is better than a longer outage just to avoid cancelling a few queries. A small non-zero value doesn't change this: short-lived clients finish on their own in milliseconds, and pooled ones don't leave.
gbartolini commentedon Nov 17, 2026
I have done a small PR #11944 and running tests on it now.
isaacvando commentedon Nov 17, 2026
Full support from us at ParadeDB. We use this configuration in our cloud and I agree that it is a better default.
MichaluxPL commentedon Nov 18, 2026
Seems like a right choice.
feat: default `smartShutdownTimeout` to 0 seconds (cloudnative-pg/clo…
feat: default `smartShutdownTimeout` to 0 seconds (cloudnative-pg#11944)