What would people here think about changing the default value of
client_connection_check_interval to 2000 ms? Right now this is disabled
by default.

The background is that I recently saw an incident where a blocking-lock
brownout escalated from a row-level problem to a complete system
outage, due to a combination of factors including a bug in golang's pgx
postgres client (PR 2481 has now been merged w a fix) and a pgbouncer
setup that was missing peers configuration. As a result, cancel
messages were getting dropped while postgres connections were waiting
on a blocked lock, golang aggresively timed out on context deadlines
and retried, and once the database reached max_connections the whole
system ground to a halt.

At the time I thought it was weird that postgres wasn't checking for
dead connections while those conns were waiting for locks; I spent a
bunch of time investigating this and reproduced it and wrote up what I
was able to figure out.

Then, yesterday, I saw a LinkedIn post from Marat at Data Egret who
mentioned that client_connection_check_interval exists.

Plugged this into my repro and confirmed it can prevent postgres from
escalating the blocking-lock brownout into a complete outage due to
connection exhaustion.

While a fix has been merged in pgx for the most direct root cause of
the incident I saw, this setting just seems like a good behavior to
make Postgres more robust in general. 2000 ms seemed like a fairly
safe/conservative starting point for discussion. Thoughts?

-Jeremy


PS. Some more details and graphs are at
https://ardentperf.com/2026/02/04/postgres-client_connection_check_interval/


-- 
To know the thoughts and deeds that have marked man's progress is to
feel the great heart throbs of humanity through the centuries; and if
one does not feel in these pulsations a heavenward striving, one must
indeed be deaf to the harmonies of life.

Helen Keller, The Story Of My Life, 1902, 1903, 1905, introduction by
Ralph Barton Perry (Garden City, NY: Doubleday & Company, 1954), p90.

>From 7936fc4ad60e40b38629f372bff397bc42a0a7f5 Mon Sep 17 00:00:00 2001
From: Jeremy Schneider <[email protected]>
Date: Wed, 4 Feb 2026 21:08:32 -0800
Subject: [PATCH] Change default client_connection_check_interval to 2000ms

The default value of client_connection_check_interval is changed from 0
(disabled) to 2000ms (2 seconds). This enables periodic checking for client
disconnection during long-running queries by default, which can help detect
and clean up queries from disconnected clients more promptly.

A value of 0 continues to disable connection checking for users who prefer
the previous behavior.
---
 src/backend/utils/misc/guc_parameters.dat     | 2 +-
 src/backend/utils/misc/postgresql.conf.sample | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/backend/utils/misc/guc_parameters.dat b/src/backend/utils/misc/guc_parameters.dat
index f0260e6e412..91c0d740ce5 100644
--- a/src/backend/utils/misc/guc_parameters.dat
+++ b/src/backend/utils/misc/guc_parameters.dat
@@ -403,7 +403,7 @@
   long_desc => '0 disables connection checks.',
   flags => 'GUC_UNIT_MS',
   variable => 'client_connection_check_interval',
-  boot_val => '0',
+  boot_val => '2000',
   min => '0',
   max => 'INT_MAX',
   check_hook => 'check_client_connection_check_interval',
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index c4f92fcdac8..8dd89d6da4e 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -87,7 +87,7 @@
 #tcp_user_timeout = 0                   # TCP_USER_TIMEOUT, in milliseconds;
                                         # 0 selects the system default
 
-#client_connection_check_interval = 0   # time between checks for client
+#client_connection_check_interval = 2000        # time between checks for client
                                         # disconnection while running queries;
                                         # 0 for never
 
-- 
2.43.0

Reply via email to