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 1sJwlk-007VEd-J4 for pgsql-admin@arkaria.postgresql.org; Wed, 19 Jun 2024 14:58:40 +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 1sJwli-000I9x-CH for pgsql-admin@arkaria.postgresql.org; Wed, 19 Jun 2024 14:58:39 +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 1sJwli-000I9p-1A for pgsql-admin@lists.postgresql.org; Wed, 19 Jun 2024 14:58:38 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sJwlg-0025rM-27 for pgsql-admin@lists.postgresql.org; Wed, 19 Jun 2024 14:58:37 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 45JEwX1v114106; Wed, 19 Jun 2024 10:58:33 -0400 From: Tom Lane To: Laurenz Albe cc: Teja Jakkidi , pgsql-admin Subject: Re: Statement_timeout in procedure block In-reply-to: <46a33904c2cd86718cb4d7a0291906a08b8e246a.camel@cybertec.at> References: <46a33904c2cd86718cb4d7a0291906a08b8e246a.camel@cybertec.at> Comments: In-reply-to Laurenz Albe message dated "Wed, 19 Jun 2024 09:24:32 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <114104.1718809113.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 19 Jun 2024 10:58:33 -0400 Message-ID: <114105.1718809113@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Laurenz Albe writes: > What works is setting the parameter on the procedure: > test=3D> CREATE OR REPLACE PROCEDURE sit() LANGUAGE plpgsql SET statemen= t_timeout =3D 2000 AS 'BEGIN PERFORM pg_sleep(5); END;'; > CREATE PROCEDURE That doesn't work either, for me, and I would not expect any of these variants to do so. The reason is that statement_timeout is defined to limit the runtime of a "statement" defined as a single command received from the client --- in this case, the CALL statement --- and the timer starts running (or doesn't) at the time of command receipt. So it's the previously-prevailing value of statement_timeout that determines what happens, and no amount of thrashing within the command will change the already-established overall timeout for it. If you're desperate, transaction_timeout might serve for this, since it looks like changes in that affect the timer immediately. But it has the effect of killing the session altogether, which is probably a bigger hammer than you want. regards, tom lane