feat: set default `tcp_user_timeout` to 5 seconds for replicas by armru · Pull Request #9317 · cloudnative-pg/cloudnative-pg

@dosubot dosubot bot added the size:L

This PR changes 100-499 lines, ignoring generated files.

label

Nov 26, 2025

@armru

The default value for TCP user timeout on standby
replication connections has changed from 0 (system default) to 5000ms
(5 seconds).

This change improves the default behavior of CloudNativePG installations
by ensuring standby instances can detect and recover from network issues
more quickly. Previously, when the network silently dropped packets,
standby instances could take up to 127 seconds (due to TCP SYN retries)
to detect a connection failure. With the new 5-second default, standby
instances will close unresponsive connections much faster and retry
connecting to the primary.

MIGRATION GUIDE FOR EXISTING INSTALLATIONS:
If you have an existing CloudNativePG installation where STANDBY_TCP_USER_TIMEOUT was not
explicitly set (defaulting to 0), and you want to preserve that behavior after upgrading,
you must now explicitly set STANDBY_TCP_USER_TIMEOUT to 0 in the cnpg-controller-manager-config
ConfigMap or Secret.

Example with ConfigMap:

  apiVersion: v1
  kind: ConfigMap
  metadata:
    name: cnpg-controller-manager-config
    namespace: cnpg-system
  data:
    STANDBY_TCP_USER_TIMEOUT: "0"

Note: If you do NOT have STANDBY_TCP_USER_TIMEOUT explicitly configured, the new default
of 5 seconds will be automatically applied on your next operator upgrade or pod restart.

For more details on TCP_USER_TIMEOUT and its behavior, see:
https://www.postgresql.org/docs/current/runtime-config-connection.html#GUC-TCP-USER-TIMEOUT

Closes #9229

Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>

@gbartolini

Signed-off-by: Gabriele Bartolini <gabriele.bartolini@enterprisedb.com>

gbartolini

@dosubot dosubot bot added the lgtm

This PR has been approved by a maintainer

label

Nov 26, 2025

leonardoce

@gbartolini gbartolini changed the title feat: change default STANDBY_TCP_USER_TIMEOUT to 5 seconds feat: set default tcp_user_timeout to 5 seconds for replicas

Nov 26, 2025