Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mVJEG-0005Qs-2Z for pgsql-general@arkaria.postgresql.org; Tue, 28 Sep 2021 19:57:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mVJEE-0004mm-2g for pgsql-general@arkaria.postgresql.org; Tue, 28 Sep 2021 19:57:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mVJED-0004me-LK for pgsql-general@lists.postgresql.org; Tue, 28 Sep 2021 19:57:25 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mVJEB-0005fW-DM for pgsql-general@lists.postgresql.org; Tue, 28 Sep 2021 19:57:24 +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 18SJvLLm2873021; Tue, 28 Sep 2021 15:57:21 -0400 From: Tom Lane To: Christophe Pettus cc: "pgsql-generallists.postgresql.org" Subject: Re: statement_timeout vs DECLARE CURSOR In-reply-to: <2767393.1632771639@sss.pgh.pa.us> References: <2767393.1632771639@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 27 Sep 2021 15:40:39 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2873019.1632859041.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 28 Sep 2021 15:57:21 -0400 Message-ID: <2873020.1632859041@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > Christophe Pettus writes: >> A bit more poking revealed the reason: The ON HOLD cursor's query is ex= ecuted at commit time (which is, logically, not interruptible), but that's= all wrapped in the single statement outside of a transaction. > Hmm ... seems like a bit of a UX failure. I wonder why we don't persist > such cursors before we get into the uninterruptible part of COMMIT. Oh, I see the issue. It's not that that part of COMMIT isn't interruptible; you can control-C out of it just fine. The problem is that finish_xact_command() disarms the statement timeout before starting CommitTransactionCommand at all. We could imagine pushing the responsibility for that down into xact.c, allowing it to happen after CommitTransaction has finished running user-defined code. But it seems like a bit of a mess because there are so many other code paths there. Not sure how to avoid future bugs-of-omission. regards, tom lane