1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-24 14:22:24 +03:00

Introduce transaction_timeout

This commit adds timeout that is expected to be used as a prevention
of long-running queries. Any session within the transaction will be
terminated after spanning longer than this timeout.

However, this timeout is not applied to prepared transactions.
Only transactions with user connections are affected.

Discussion: https://postgr.es/m/CAAhFRxiQsRs2Eq5kCo9nXE3HTugsAAJdSQSmxncivebAxdmBjQ%40mail.gmail.com
Author: Andrey Borodin <amborodin@acm.org>
Author: Japin Li <japinli@hotmail.com>
Author: Junwang Zhao <zhjwpku@gmail.com>
Reviewed-by: Nikolay Samokhvalov <samokhvalov@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Fujii Masao <masao.fujii@oss.nttdata.com>
Reviewed-by: bt23nguyent <bt23nguyent@oss.nttdata.com>
Reviewed-by: Yuhang Qiu <iamqyh@gmail.com>
This commit is contained in:
Alexander Korotkov
2024-02-15 23:34:11 +02:00
parent 5c9f2f9398
commit 51efe38cb9
23 changed files with 343 additions and 5 deletions

View File

@ -9140,6 +9140,42 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
</listitem>
</varlistentry>
<varlistentry id="guc-transaction-timeout" xreflabel="transaction_timeout">
<term><varname>transaction_timeout</varname> (<type>integer</type>)
<indexterm>
<primary><varname>transaction_timeout</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
Terminate any session that spans longer than the specified amount of
time in the transaction. The limit applies both to explicit transactions
(started with <command>BEGIN</command>) and to an implicitly started
transaction corresponding to a single statement.
If this value is specified without units, it is taken as milliseconds.
A value of zero (the default) disables the timeout.
</para>
<para>
If <varname>transaction_timeout</varname> is shorter or equal to
<varname>idle_in_transaction_session_timeout</varname> or <varname>statement_timeout</varname>
<varname>transaction_timeout</varname> will invalidate the longer timeout.
</para>
<para>
Setting <varname>transaction_timeout</varname> in
<filename>postgresql.conf</filename> is not recommended because it would
affect all sessions.
</para>
<note>
<para>
Prepared transactions are not subject to this timeout.
</para>
</note>
</listitem>
</varlistentry>
<varlistentry id="guc-lock-timeout" xreflabel="lock_timeout">
<term><varname>lock_timeout</varname> (<type>integer</type>)
<indexterm>