Re: Request: pg_cancel_backend variant that handles 'idle in transaction' sessions

From: Joe Conway <mail(at)joeconway(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Merlin Moncure <mmoncure(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, David Steele <david(at)pgmasters(dot)net>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Request: pg_cancel_backend variant that handles 'idle in transaction' sessions
Date: 2015-11-05 18:56:54
Message-ID: 563BA676.8040800@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11/05/2015 10:48 AM, Pavel Stehule wrote:
> S
> t C
> a<-------------<transaction>--------------->E
> r A B A B A n
> t <idle> <stmt> <idle> <stmt> <idle> d
> |--------======--------======---------------|
>
> Currently we can set timeout and cancel for period B (<stmt>). I can see
> based on this discussion that there are legitimate use cases for wanting
> timeout and cancel for any of the periods A, B, or C.
>
> I guess the question then becomes how we provide that coverage. I think
> for coverage of timeout you need three individual timeout settings.
> However for cancel, it would seem that pg_cancel_transaction would cover
> all three cases.
>
>
> It can be difficult to set it properly, because you don't know how much
> statements (cycles of A.B) will be in transaction. Respective for
> setting C, I have to know the number of A,B and it isn't possible everytime.

But you might have a limit you want to enforce regardless of the size or
quantity of A & B periods. That's why it needs to be a separate timeout
IMHO. Let's say I never want a transaction to be around more than 60
minutes no matter what. But I also don't want idle in transaction to
ever exceed 30 seconds, and I don't expect individual statements to
exceed 10 minutes.

Joe

--
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2015-11-05 19:02:00 Re: Request: pg_cancel_backend variant that handles 'idle in transaction' sessions
Previous Message Pavel Stehule 2015-11-05 18:48:04 Re: Request: pg_cancel_backend variant that handles 'idle in transaction' sessions