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.94.2) (envelope-from ) id 1svP4B-00EmI7-Lw for pgsql-general@arkaria.postgresql.org; Mon, 30 Sep 2024 22:40:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1svP4A-006qw2-4c for pgsql-general@arkaria.postgresql.org; Mon, 30 Sep 2024 22:40:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1svP48-006qtX-LK for pgsql-general@lists.postgresql.org; Mon, 30 Sep 2024 22:40:29 +0000 Received: from fout-a2-smtp.messagingengine.com ([103.168.172.145]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1svP45-001rJo-F8 for pgsql-general@lists.postgresql.org; Mon, 30 Sep 2024 22:40:27 +0000 Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfout.phl.internal (Postfix) with ESMTP id 149B31380AC9; Mon, 30 Sep 2024 18:40:24 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-10.internal (MEProxy); Mon, 30 Sep 2024 18:40:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1727736024; x=1727822424; bh=FyPv54Yg7xZxP5EEdvXkNHii5MZmbChT54715ksFxXw=; b= qD7xccqvRqvXAx0fe8h7ZIiDi/RwmdTAjFPUkdtXjyKGJh1LDtAoT+wpVggDzVq3 H7Qa4gdiHf+LnWhHbIun8JM6LBn63tGu+vkAizisDrQ3T9uDOYv/MxmU/oJQN2s+ Zoq/OHom75bYvMOsI2Vmta+9lF9ws+5TY6roxro+T51tBMx8qjcJAzunecFESVgg 8lzRvV/Wv+zhOeM/uk2RM/EeTduVABsjzG1t4KZzz7wo+9OHtxhB+eZyHahewC8b qEZ5iiei8I1bZvvNLXxFw1txOwpKvIrENc2aAOL+MRnMgGZnPIkqnm7YOC89FAhn DZ1wpWtgHk5J15hsd3fuQQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1727736024; x= 1727822424; bh=FyPv54Yg7xZxP5EEdvXkNHii5MZmbChT54715ksFxXw=; b=S PA82wBhO8GuD6PxVZamz2m9ae3bftg+tYhFNR1G+1ipxZVyomWH+QzcGo2b635EA AKu2dA5o8zD0O1LihINZ0wWFycVPw8YS2GyTrw5sf+2Gb4S8taKUtZbPLUdJxeYD xZSGIsyvNViFH0gA3i3/Dt+9zz6GfZRpehOfFnJzjufMGavkhEcWCv2VBnjNq1EG wiJg6lom+G0bN8saecXg1Hm94H5f/39I+UVWDtv713GQFYhYESL17gtSJvv7LxnX a3zH65ugx6B2gPWlZrCN6+hjVwbf6mgxYbDgt7uBU5cxu3YVR2gdemj0IKFokoZM UI/LT29lRDqVR/SNM4Gbw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdduiedgudefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefkffggfg fuvfhfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghr uceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrth htvghrnhepkeefheduvdejiefgieefjedtudduffelvdefleehfedtieffuefgvdekleeg tddvnecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrghenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghr segrkhhlrghvvghrrdgtohhmpdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpoh huthdprhgtphhtthhopehsuhgushdugeefgeesghhmrghilhdrtghomhdprhgtphhtthho pehpghhsqhhlqdhgvghnvghrrghlsehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 30 Sep 2024 18:40:23 -0400 (EDT) Message-ID: <3133182a-35c4-4a81-be60-8ab227c0fbc0@aklaver.com> Date: Mon, 30 Sep 2024 15:40:22 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Question on session timeout To: sud , pgsql-general References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 9/30/24 13:01, sud wrote: > Hello, > We are frequently seeing the total DB connection reaching ~2000+ whereas Where are you getting the ~2000 count from? > the total number of active sessions in pg_stat_activity staying <100 at > any point in time. And when we see the sessions from DB side they are > showing most of the sessions with state as 'idle' having > backend_start/xact_start showing date ~10days older. We do use > application level connection pooling, and we have ~120 sets as both the What do you mean by ~120 sets, in particular what is a set? > "max idle" and "max active" connection count and "maxage" as 7 days, so > does this suggest any issue at connection pool setup? Using what pooler? > > We do see keep alive queries in the DB (select 1), not sure if that is > making this scenario. When checking the How often do to keep alive queries run? > "idle_in_transaction_session_timeout" it is set as 24hours and > "idle_session_timeout" set as "0". So my question is , should we set the > parameter to a lesser value in DB cluster level like ~5minutes or so, so > as not to keep the idle sessions lying so long in the database and what '"idle_in_transaction_session_timeout" it is set as 24hours' is a foot gun as explained here: https://www.postgresql.org/docs/current/runtime-config-client.html idle_in_transaction_session_timeout (integer) [...] "This option can be used to ensure that idle sessions do not hold locks for an unreasonable amount of time. Even when no significant locks are held, an open transaction prevents vacuuming away recently-dead tuples that may be visible only to this transaction; so remaining idle for a long time can contribute to table bloat. See Section 24.1 for more details." With '"idle_session_timeout" set as "0"' a session without an open transaction is not going to timeout. > would be the advisable value for these parameters? > > Regards > Sud -- Adrian Klaver adrian.klaver@aklaver.com