Re: Transaction timeout

Andrey Borodin <amborodin86@gmail.com>

From: Andrey Borodin <amborodin86@gmail.com>
To: Nikolay Samokhvalov <samokhvalov@gmail.com>
Cc: Nathan Bossart <nathandbossart@gmail.com>, Andres Freund <andres@anarazel.de>, Michael Paquier <michael.paquier@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2023-01-13T18:15:56Z
Lists: pgsql-hackers
Thanks for the review Nikolay!

On Fri, Jan 13, 2023 at 8:03 AM Nikolay Samokhvalov
<samokhvalov@gmail.com> wrote:
>
> 1) The current test set has only 2 simple cases – I'd suggest adding one more (that one that didn't work in v1):
>
> gitpod=# set transaction_timeout to '20ms';
> SET
> gitpod=# begin; select pg_sleep(.01); select pg_sleep(.01); select pg_sleep(.01); commit;
I tried exactly these tests - tests were unstable on Windows. Maybe
that OS has a more coarse-grained timer resolution.
It's a tradeoff between time spent on tests, strength of the test and
probability of false failure. I chose small time without false alarms.

> – it seems we could (should) have one more successful "1s wait, 3s sleep" iteration here, ~727ms somehow wasted in a loop, quite a lot.

I think big chunk from these 727ms were spent between "BEGIN" and
"select now(), clock_timestamp(), pg_sleep(3) \watch 1". I doubt patch
really contains arithmetic errors.

Many thanks for looking into this!


Best regards, Andrey Borodin.



Commits

  1. Add TAP tests for timeouts

  2. Remove flaky isolation tests for timeouts

  3. Followup fixes for transaction_timeout

  4. Introduce transaction_timeout

  5. On systems that have setsid(2) (which should be just about everything except