Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vnrww-00CniW-1x for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Feb 2026 05:30:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vnrwv-00FON3-2R for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Feb 2026 05:30:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vnrwv-00FOMv-1D for pgsql-hackers@lists.postgresql.org; Thu, 05 Feb 2026 05:30:41 +0000 Received: from mail-dy1-x132d.google.com ([2607:f8b0:4864:20::132d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vnrws-000000018vg-2WZm for pgsql-hackers@lists.postgresql.org; Thu, 05 Feb 2026 05:30:40 +0000 Received: by mail-dy1-x132d.google.com with SMTP id 5a478bee46e88-2b8397e3e09so767414eec.0 for ; Wed, 04 Feb 2026 21:30:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ardentperf-com.20230601.gappssmtp.com; s=20230601; t=1770269436; x=1770874236; darn=lists.postgresql.org; h=mime-version:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to; bh=75KYo8LdXH6yKu/jBJ5nPr578stNWqPls1LTYkMhKNE=; b=BvouzsPP8bj2yM/ZIPBfKukvEi+M2muDU9rGc8AH7kTt/VxlMF1DxfOiGI4ak1dbVr hXgxEzfkgPKwNoLnrGvX9yY8ENFXpFbXl2LzhKIa+nEMez61glM8PM4XSc9pGjj1NkTa q2dLv10JiwOBXTHY+KvJrbjrvlrX56+A/62Pj7LzRcGt3se3lcLL6xQbnbFmGPWMrkUr g/b58M1rlklW+ZCw3t6WuVAbiAUb24+IomjL5Lz5g1xL+eKMU8+9xhWfmDbeO8Hznmbf iIN31K5+MXJnUsg6cJ0mj/YrofjRoEjdNDJBeRFcdL0t2P7BI/aO+pKD/rMiSheYKOGo Comg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770269436; x=1770874236; h=mime-version:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=75KYo8LdXH6yKu/jBJ5nPr578stNWqPls1LTYkMhKNE=; b=iJIFIocgC0mYSf5ViUyiLWIgcAHEPhTLbxe7JiuhXyEKe6C2Ux1FaFv2Ev/N20g/lD 1GnmhPee99cd/6WxnWoip79kgakWRmjgXODD68OjLLPf5mKSTHzdzBqS5HG00d4G79Md 4+lnvuxn3q4X5QfuzFTJZbkmzTzYZcpePG4dXrrpAyO0ZsIQzzrflP//HZWOCuUqv7M0 RXkgCATq3WzftOieg9QtOIn9dQBYELPo2COLDlipmi7JxFnHm57Z7tQPJ39tKOmBrJSf mkbd2ymDHMdlh9yLO5ARH7farYxhIRZ92hqhChNKw5oB1JCZD/vknY7M22EhpVinIyUY SPNg== X-Gm-Message-State: AOJu0YzS+E1IHqHU0b/d/jD1z89e4PbUYsIy18SfEbt8JYI1NvXp8fRC +BVejWd/t4GSRjThqzM3PzXvomOaIL4tWQdCc8hqaNln6ItEcaq/94+Dzl/GFX+QKv/BIGBQ3Gi WU28= X-Gm-Gg: AZuq6aJGUw8BM4+h1TSljl+cN7Rm2nS8ADkt6x1UyWD5WUPeA9oL14r3EZ8CAPyr0Sc HAQ63bmN08Iq6sYgBH6Fbp7ek+PWiMpDSs9JAiTO7cEGdIUHv/k5OEcAV+DE8fUP0uh6FS1i3JN 4OJiyATzEmG6wfX6pEcJCM4OUkJrEvm3qAL01+M7LJRNFzwY0aK9DOGAOmRGv9u9JoOt83k60mV AjNsc/e2dmydmfL69d7DHK1R9TED7HwZoD2C5Pn/kkS0gsZNJng6XX3nRIqKbiAHoSQ2FYSesrb 1j8ZeEZyotSd46Atqgzlq+avywShp5IQ+Y563cbCK3+tyW5xjbozy2rFeMhVeKKTrXN/Vxfl35/ fSuVRXZ7cVInOGVh2M8WCATTzUsSgl5qrRQjaJftSQNkNsO8OfBht2NLpJX8In1EZbNPxxO+StP X5oeo6hMrS3H3HVtkrqyzHYC6r/zKu6zbuwdTtMD9xDw3JDLh5aQvoT2cfwYWkXepJQyOZz9i7L +YOzcUHOD8EOmq3 X-Received: by 2002:a05:7300:3c05:b0:2b7:32a6:82bc with SMTP id 5a478bee46e88-2b8329df7f6mr2450397eec.26.1770269436012; Wed, 04 Feb 2026 21:30:36 -0800 (PST) Received: from ardentperf.com (97-113-67-23.tukw.qwest.net. [97.113.67.23]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b832e4d18fsm2638453eec.13.2026.02.04.21.30.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Feb 2026 21:30:35 -0800 (PST) Date: Wed, 4 Feb 2026 21:30:32 -0800 From: Jeremy Schneider To: "pgsql-hackers@lists.postgresql.org" Cc: Marat Buharov Subject: client_connection_check_interval default value Message-ID: <20260204213032.15bab46b@ardentperf.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/jM6_r96OH5VgTm.Dm/FNCyc" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --MP_/jM6_r96OH5VgTm.Dm/FNCyc Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline 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. --MP_/jM6_r96OH5VgTm.Dm/FNCyc Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-Change-default-client_connection_check_interval-to-2.patch From 7936fc4ad60e40b38629f372bff397bc42a0a7f5 Mon Sep 17 00:00:00 2001 From: Jeremy Schneider 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 --MP_/jM6_r96OH5VgTm.Dm/FNCyc--