Re: [BUGS] BUG #14821: idle_in_transaction_session_timeout sometimesgets ignored when statement timeout is pending - Mailing list pgsql-bugs

From Lukas Fittl
Subject Re: [BUGS] BUG #14821: idle_in_transaction_session_timeout sometimesgets ignored when statement timeout is pending
Date
Msg-id CAP53Pkwyrw_4funJh7V=2C2OmTp+9VK8vp=xkwcqTj5j1KS60g@mail.gmail.com
Whole thread Raw
In response to Re: [BUGS] BUG #14821: idle_in_transaction_session_timeout sometimesgets ignored when statement timeout is pending  (Andres Freund <andres@anarazel.de>)
List pgsql-bugs
Hi,

On Wed, Sep 20, 2017 at 6:29 PM, Andres Freund <andres@anarazel.de> wrote:
Hi,

On 2017-09-21 01:09:56 +0000, lukas@fittl.com wrote:
> It seems to me that ProcessInterrupts() should check for the idle in
> transaction timeout first, since it short-circuits and returns early if
> QueryCancelPending && QueryCancelHoldoffCount != 0 before even getting
> there.

Indeed - although I wonder if the correct fix isn't to move things
around, but to instead avoid the order dependency changing the short
circuit logic so that there's no early return. Like e.g.

        if (QueryCancelPending && QueryCancelHoldoffCount != 0)
        {
                /* rearm */
        }
        else if (QueryCancelPending)
        {
                /* handle interrupt */
        }

there's really no good reason for the return right now, and it's bound
to create more bugs in the future.

That seems like a reasonable approach and a good idea.

I'll take a stab at making a patch for this tonight and send it over to hackers then.

Best,
Lukas

--
Lukas Fittl

Skype: lfittl
Phone: +1 415 321 0630

pgsql-bugs by date:

Previous
From: Andres Freund
Date:
Subject: Re: [BUGS] BUG #14821: idle_in_transaction_session_timeout sometimesgets ignored when statement timeout is pending
Next
From: Lukas Fittl
Date:
Subject: Re: [BUGS] BUG #14821: idle_in_transaction_session_timeout sometimesgets ignored when statement timeout is pending