Re: statement_timeout vs DECLARE CURSOR

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Christophe Pettus <xof(at)thebuild(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: statement_timeout vs DECLARE CURSOR
Date: 2021-09-28 20:15:14
Message-ID: 2899369.1632860114@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

[ redirect to -hackers ]

I wrote:
>> Christophe Pettus <xof(at)thebuild(dot)com> writes:
>>> A bit more poking revealed the reason: The ON HOLD cursor's query is executed 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.

Actually ... maybe it needn't be any harder than the attached?

This makes it possible for a statement timeout interrupt to occur
anytime during CommitTransactionCommand, but I think
CommitTransactionCommand had better be able to protect itself
against that anyway, for a couple of reasons:

1. It's not significantly different from a query-cancel interrupt,
which surely could arrive during that window.

2. COMMIT-within-procedures already exposes us to statement timeout
during COMMIT.

regards, tom lane

Attachment Content-Type Size
include-commit-processing-in-statement-timeout.patch text/x-diff 590 bytes

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Abhishek B 2021-09-29 09:01:46 postgresql11: How to use publication/subscription on primary/standby setup
Previous Message Tom Lane 2021-09-28 19:57:21 Re: statement_timeout vs DECLARE CURSOR

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Fone 2021-09-28 21:58:49 Re: pgcrypto support for bcrypt $2b$ hashes
Previous Message Tom Lane 2021-09-28 19:57:21 Re: statement_timeout vs DECLARE CURSOR