Re: Transaction timeout

From: Li Japin <japinli(at)hotmail(dot)com>
To: Junwang Zhao <zhjwpku(at)gmail(dot)com>
Cc: "Andrey M(dot) Borodin" <x4mmm(at)yandex-team(dot)ru>, 邱宇航 <iamqyh(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, Andrey Borodin <amborodin86(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Nikolay Samokhvalov <samokhvalov(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Transaction timeout
Date: 2023-12-23 06:48:14
Message-ID: ME3P282MB31664A5018CEC4782D2DA7DAB69BA@ME3P282MB3166.AUSP282.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> 在 2023年12月23日,11:35,Junwang Zhao <zhjwpku(at)gmail(dot)com> 写道:
>
> On Sat, Dec 23, 2023 at 11:17 AM Japin Li <japinli(at)hotmail(dot)com> wrote:
>>
>> a
>>> On Sat, 23 Dec 2023 at 10:40, Japin Li <japinli(at)hotmail(dot)com> wrote:
>>> On Sat, 23 Dec 2023 at 08:32, Japin Li <japinli(at)hotmail(dot)com> wrote:
>>>> On Fri, 22 Dec 2023 at 23:30, Junwang Zhao <zhjwpku(at)gmail(dot)com> wrote:
>>>>> On Fri, Dec 22, 2023 at 10:44 PM Japin Li <japinli(at)hotmail(dot)com> wrote:
>>>>>>
>>>>>>
>>>>>> On Fri, 22 Dec 2023 at 22:37, Junwang Zhao <zhjwpku(at)gmail(dot)com> wrote:
>>>>>>> On Fri, Dec 22, 2023 at 10:25 PM Japin Li <japinli(at)hotmail(dot)com> wrote:
>>>>>>>> I try to set idle_in_transaction_session_timeout after begin transaction,
>>>>>>>> it changes immediately, so I think transaction_timeout should also be take
>>>>>>>> immediately.
>>>>>>>
>>>>>>> Ah, right, idle_in_transaction_session_timeout is set after the set
>>>>>>> command finishes and before the backend send *ready for query*
>>>>>>> to the client, so the value of the GUC is already set before
>>>>>>> next command.
>>>>>>>
>>>>>>
>>>>>> I mean, is it possible to set transaction_timeout before next comand?
>>>>>>
>>>>> Yeah, it's possible, set transaction_timeout in the when it first
>>>>> goes into *idle in transaction* mode, see the attached files.
>>>>>
>>>>
>>>> Thanks for updating the patch, LGTM.
>>>
>>> Sorry for the noise!
>>>
>>> Read the previous threads, I find why the author enable transaction_timeout
>>> in start_xact_command().
>>>
>>> The v15 patch cannot handle COMMIT AND CHAIN, see [1]. For example:
>>>
>>> SET transaction_timeout TO '2s'; BEGIN; SELECT 1, pg_sleep(1); COMMIT AND CHAIN; SELECT 2, pg_sleep(1); COMMIT;
>>>
>>> The transaction_timeout do not reset when executing COMMIT AND CHAIN.
>>>
>>> [1] https://www.postgresql.org/message-id/a906dea1-76a1-4f26-76c5-a7efad3ef5b8%40oss.nttdata.com
>>
>> Attach v16 to solve this. Any suggestions?
>
> I've checked this with *COMMIT AND CHAIN* and *ABORT AND CHAIN*,
> both work as expected. Thanks for the update.
>

Thanks for your testing and reviewing!

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2023-12-23 07:22:07 Re: Fixing pgbench init overflow
Previous Message Japin Li 2023-12-23 05:23:44 Re: Fixing pgbench init overflow