Re: [BUGS] BUG #14821: idle_in_transaction_session_timeout sometimes gets ignored when statement timeout is pending

From: Lukas Fittl <lukas(at)fittl(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Cc: Andres Freund <andres(at)anarazel(dot)de>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: [BUGS] BUG #14821: idle_in_transaction_session_timeout sometimes gets ignored when statement timeout is pending
Date: 2017-09-21 03:27:05
Message-ID: CAP53PkxQnv3OWJpyNPGJYT62uY=n1=2CF_Lpc6gVOFnc0-gazw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Hi,

As per the bug report at
https://www.postgresql.org/message-id/20170921010956.17345.61461%40wrigleys.postgresql.org
it seems that the query cancellation holdoff logic in ProcessInterrupts is
a bit overly aggressive in keeping other interrupts from running.

In particular I've seen an issue in the wild where
idle_in_transaction_session_timeout did not get triggered because
the HOLD_CANCEL_INTERRUPTS() in SocketBackend wraps around a pq_getbyte()
call, and so ProcessInterrupts doesn't do anything when it gets called
because the query cancel holdoff counter is positive.

Andres suggested the following re-ordering of the logic on -bugs:

> On Wed, Sep 20, 2017 at 6:29 PM, Andres Freund <andres(at)anarazel(dot)de> wrote:
>>
>>
>> if (QueryCancelPending && QueryCancelHoldoffCount != 0)
>> {
>> /* rearm */
>> }
>> else if (QueryCancelPending)
>> {
>> /* handle interrupt */
>> }
>>
>
Which is implemented in the attached patch.

Unless someone wants to pick this up right away, I'll register it in the
next commitfest tomorrow.

Best,
Lukas

--
Lukas Fittl

Attachment Content-Type Size
0001-Only-skip-query-cancel-itself-when-query-cancel-hold.patch application/octet-stream 2.1 KB

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message IT Support 2017-09-21 06:37:38 pg_basebackup
Previous Message Lukas Fittl 2017-09-21 01:39:23 Re: BUG #14821: idle_in_transaction_session_timeout sometimes gets ignored when statement timeout is pending

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2017-09-21 03:35:02 Re: POC: Cache data in GetSnapshotData()
Previous Message Andres Freund 2017-09-21 02:32:36 Re: POC: Cache data in GetSnapshotData()