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 1v1mzE-00CfVt-Tv for pgsql-novice@arkaria.postgresql.org; Thu, 25 Sep 2025 14:30:21 +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 1v1mzD-003Gm5-B0 for pgsql-novice@arkaria.postgresql.org; Thu, 25 Sep 2025 14:30:19 +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 1v1mzC-003Glx-BP for pgsql-novice@lists.postgresql.org; Thu, 25 Sep 2025 14:30:19 +0000 Received: from fout-a7-smtp.messagingengine.com ([103.168.172.150]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1v1mz6-002Nc7-2S for pgsql-novice@postgresql.org; Thu, 25 Sep 2025 14:30:17 +0000 Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfout.phl.internal (Postfix) with ESMTP id 6EF89EC0180; Thu, 25 Sep 2025 10:30:11 -0400 (EDT) Received: from phl-imap-16 ([10.202.2.88]) by phl-compute-09.internal (MEProxy); Thu, 25 Sep 2025 10:30:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=de.me.tz; h=cc :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=fm2; t=1758810611; x=1758897011; bh=zqN4iQYpDOAjGVjbBsJU2Ph4NybLcWh5BzKpmfR0IWs=; b= 1uulNWTm05lRniUqpS7VE86PHpHGp3YASbwgXYnE8g9SkFP3GHvOIXq4UYWrgB+K Agx0/nYi1SLuCb696YeWrfMGyXc8/bQMC7Yj+BvqxxNsxn5r3xb3GvHQeUH+p4yG hEqFU8FLBFZaERbXJ3eCqk5aVzvM0DDfNclqGqN0ANFf4O99UzcRsfy+qz68dLFJ uMhr37VmAKMKyZtKmFFmHyGNyxOC8mO3LOD0KtTol1KCiX0FTglIYEZpGnr7DGHC qL0xsoYF4A/ABL/qJlI2ra+rcnT8Xpic0mwOsCyPupu23T1u91hJM4a4Tev5tMDK YzQYjCitTbM1wy2yJBqzpg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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-sender:x-me-sender:x-sasl-enc; s=fm1; t=1758810611; x= 1758897011; bh=zqN4iQYpDOAjGVjbBsJU2Ph4NybLcWh5BzKpmfR0IWs=; b=L eix9VYEKye3eUQ1VwqH8q8v9pJ/RUgekhGk/vmHiEeLCtdjYE6baJ11QBpd0TxWj 3YqerGGUNx5kpQJli5mk7JvoQa+fxUGwbaybKDju/qOESK0Gv1yNUaZPjg/qlcRq AXhT/H+zOE9b4/24BGI5WgyP0rjlmCr48oLD8NUueU2APkwny0fOEsueFgWiuEi9 wFYpqB26AJnX7FU7aTup2gFPVfsIOTxvkY0DVsnku+DHMlNdj86yKtHNsGABM9rl DAy8raLxzkEMIFrcmd0dPvPSpxpg1Sh7xv8ff+bcv0nd2TnH0wTPy8wLb6hRB5xb H/vDTZfmfaw0M1GsrLrkw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdeiieejfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhepofggfffhvfevkfgjfhfutgfgsehtjeertd ertddtnecuhfhrohhmpedfsfhuvghnthhinhcuuggvucfovghtiidfuceoqhhuvghnthhi nhesuggvrdhmvgdrthiiqeenucggtffrrghtthgvrhhnpeehleettdejteeiuedtffevhf fgvefhgfetkeegudeludeukeevieevieduieduvdenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpehquhgvnhhtihhnseguvgdrmhgvrdhtiidpnh gspghrtghpthhtohepiedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheprghmsgho rhhoughinhesrggtmhdrohhrghdprhgtphhtthhopegrvghkohhrohhtkhhovhesghhmrg hilhdrtghomhdprhgtphhtthhopeiihhhjfihpkhhusehgmhgrihhlrdgtohhmpdhrtghp thhtohepjhgrphhinhhliheshhhothhmrghilhdrtghomhdprhgtphhtthhopehpghhsqh hlqdhnohhvihgtvgesphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthhtohepgiegmhhm mheshigrnhguvgigqdhtvggrmhdrrhhu X-ME-Proxy: Feedback-ID: i7a6842ed:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id D60162CC008C; Thu, 25 Sep 2025 10:30:10 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 X-ThreadId: AB6uwmaXg6vF Date: Thu, 25 Sep 2025 16:29:50 +0200 From: "Quentin de Metz" To: x4mmm@yandex-team.ru Cc: pgsql-novice@postgresql.org, amborodin@acm.org, aekorotkov@gmail.com, japinli@hotmail.com, zhjwpku@gmail.com Message-Id: <97dbb3e1-6f2b-4e15-9c63-68609fd428c8@app.fastmail.com> In-Reply-To: <34EA56AD-712D-4DEF-91B9-74FA1673A95D@yandex-team.ru> References: <554670a7-7560-4d18-8ecb-8518fddf2b9d@app.fastmail.com> <34EA56AD-712D-4DEF-91B9-74FA1673A95D@yandex-team.ru> Subject: Re: SET transaction_timeout inside a transaction Content-Type: text/plain Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Andrey, The answers from the other participants in this thread make sense. My application has tooling to modify connection variables (e.g. statement_timeout) around specific queries, most of which can be set inside or outside the transaction with the same practical consequences. This is simply the first time we need to explicitly set a variable before opening the transaction. We'll make the necessary modifications at the application layer. Regards, Quentin de Metz On Sat, Sep 20, 2025, at 07:41, x4mmm@yandex-team.ru wrote: > On 20 Sep 2025, at 1:12, Quentin de Metz wrote: > >> It appears that changing the transaction_timeout when inside a transaction does not work as expected. >> >> Running the following script on master: >> >> SET transaction_timeout = '1s'; >> BEGIN; >> SET transaction_timeout = '3s'; >> SELECT pg_sleep(2); >> >> Fails with the following: >> >> FATAL: terminating connection due to transaction timeout >> server closed the connection unexpectedly >> This probably means the server terminated abnormally >> before or while processing the request. >> >> A workaround is to "SET transaction_timeout = 0" before each override. But this resets the timer, which may not be aligned with this parameter's intention. >> > > Hi Quentin! > > Thanks for raising this, it's very good to hear more about usage > patterns, it really helps to improve. > > Together with reviewers we did consider "extending" transaction > timeout. But the problem is it promotes very unreliable coding pattern: > adjusting time budget without checking how many time is already spent. > > Yes, if expectations of your transaction changed you can reset > transaction_timeout and set new time budget. Personally, I don't like > it either. But it did not seem a good idea to forbid resetting timeout > at all or to forbid setting it amid of a transaction: we needed both > this functionalities for "SET transaction_timeout = x;" to work. > > It's hard to change anything radically in shipped feature. But, if > possible, please, tell more about usage patterns beyond pg_sleep(), > maybe our assumptions were not accurate enough and we could do better > in future. > > > Best regards, Andrey Borodin.