Re: Transaction timeout - Mailing list pgsql-hackers

From Andrey Borodin
Subject Re: Transaction timeout
Date
Msg-id CAAhFRxgdXGNRiaMgd+cVCjzcrj1e_7KyAE200KSPD19+-Di5Rw@mail.gmail.com
Whole thread Raw
In response to Re: Transaction timeout  (Andres Freund <andres@anarazel.de>)
Responses Re: Transaction timeout  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
Thanks for looking into this Andres!

On Mon, Dec 5, 2022 at 3:07 PM Andres Freund <andres@anarazel.de> wrote:
>
> I'm a bit worried about adding evermore branches and function calls for
> the processing of single statements. We already spend a noticable
> percentage of the cycles for a single statement in PostgresMain(), this
> adds additional overhead.
>
> I'm somewhat inclined to think that we need some redesign here before we
> add more overhead.
>
We can cap statement_timeout\idle_session_timeout by the budget of
transaction_timeout left.
Either way we can do batch function enable_timeouts() instead
enable_timeout_after().

Does anything of it make sense?

>
> > @@ -1360,6 +1363,16 @@ IdleInTransactionSessionTimeoutHandler(void)
> >       SetLatch(MyLatch);
> >  }
> >
> > +static void
> > +TransactionTimeoutHandler(void)
> > +{
> > +#ifdef HAVE_SETSID
> > +     /* try to signal whole process group */
> > +     kill(-MyProcPid, SIGINT);
> > +#endif
> > +     kill(MyProcPid, SIGINT);
> > +}
> > +
>
> Why does this use signals instead of just setting the latch like
> IdleInTransactionSessionTimeoutHandler() etc?

I just copied statement_timeout behaviour. As I understand this
implementation is prefered if the timeout can catch the backend
running at full steam.

> > diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
> > index 0081873a72..5229fe3555 100644
> > --- a/src/bin/pg_dump/pg_backup_archiver.c
> > +++ b/src/bin/pg_dump/pg_backup_archiver.c
> > @@ -3089,6 +3089,7 @@ _doSetFixedOutputState(ArchiveHandle *AH)
> >       ahprintf(AH, "SET statement_timeout = 0;\n");
> >       ahprintf(AH, "SET lock_timeout = 0;\n");
> >       ahprintf(AH, "SET idle_in_transaction_session_timeout = 0;\n");
> > +     ahprintf(AH, "SET transaction_timeout = 0;\n");
>
> Hm - why is that the right thing to do?
Because transaction_timeout has effects of statement_timeout.

Thank you!

Best regards, Andrey Borodin.



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [PATCH] Add native windows on arm64 support
Next
From: Andres Freund
Date:
Subject: Re: Error-safe user functions