Skip to content

Change the default of .spec.smartShutdownTimeout from 180 to 0 seconds #11943

Description

@gbartolini

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):

  1. CHECKPOINT, then a smart shutdown, for up to smartShutdownTimeout seconds (default 180). A smart shutdown disallows new connections and waits for every existing client to disconnect on its own.
  2. If Postgres is still up, a fast shutdown (preceded by another CHECKPOINT), which terminates existing connections. It waits up to stopDelay, which is the Pod's termination grace period.

The default is defined in two places:

  • the +kubebuilder:default:=180 marker on SmartShutdownTimeout (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 0 and update the field's doc comment.
  • Change the fallback in GetSmartShutdownTimeout() to 0, 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 0 path.

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 set smartShutdownTimeout: 180 explicitly.
  • 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 0 the 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?

Activity

  1. added this to the 1.31.0 milestone on Nov 17, 2026
  2. added theissue type on Nov 17, 2026
  3. added
    enhancement 🪄
    on Nov 17, 2026
  4. mnencia commented on Nov 17, 2026

    @mnencia
    Member

    I agree, 0 is 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.

  5. gbartolini commented on Nov 17, 2026

    @gbartolini
    ContributorAuthor

    I have done a small PR #11944 and running tests on it now.

  6. isaacvando commented on Nov 17, 2026

    @isaacvando

    Full support from us at ParadeDB. We use this configuration in our cloud and I agree that it is a better default.

  7. MichaluxPL commented on Nov 18, 2026

    @MichaluxPL
    Contributor

    Seems like a right choice.

  8. added a commit that references this issue on Nov 18, 2026
    fabc841
  9. added a commit that references this issue on Nov 18, 2026
    78a018f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement 🪄

    Type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions