1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-08 06:02:22 +03:00

Add lock_timeout configuration parameter.

This GUC allows limiting the time spent waiting to acquire any one
heavyweight lock.

In support of this, improve the recently-added timeout infrastructure
to permit efficiently enabling or disabling multiple timeouts at once.
That reduces the performance hit from turning on lock_timeout, though
it's still not zero.

Zoltán Böszörményi, reviewed by Tom Lane,
Stephen Frost, and Hari Babu
This commit is contained in:
Tom Lane
2013-03-16 23:22:17 -04:00
parent d2bef5f7db
commit d43837d030
16 changed files with 511 additions and 116 deletions

View File

@@ -5077,7 +5077,7 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
</indexterm>
<listitem>
<para>
Abort any statement that takes over the specified number of
Abort any statement that takes more than the specified number of
milliseconds, starting from the time the command arrives at the server
from the client. If <varname>log_min_error_statement</> is set to
<literal>ERROR</> or lower, the statement that timed out will also be
@@ -5086,8 +5086,42 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
<para>
Setting <varname>statement_timeout</> in
<filename>postgresql.conf</> is not recommended because it
affects all sessions.
<filename>postgresql.conf</> is not recommended because it would
affect all sessions.
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-lock-timeout" xreflabel="lock_timeout">
<term><varname>lock_timeout</varname> (<type>integer</type>)</term>
<indexterm>
<primary><varname>lock_timeout</> configuration parameter</primary>
</indexterm>
<listitem>
<para>
Abort any statement that waits longer than the specified number of
milliseconds while attempting to acquire a lock on a table, index,
row, or other database object. The time limit applies separately to
each lock acquisition attempt. The limit applies both to explicit
locking requests (such as <command>LOCK TABLE</>, or <command>SELECT
FOR UPDATE</> without <literal>NOWAIT</>) and to implicitly-acquired
locks. If <varname>log_min_error_statement</> is set to
<literal>ERROR</> or lower, the statement that timed out will be
logged. A value of zero (the default) turns this off.
</para>
<para>
Unlike <varname>statement_timeout</>, this timeout can only occur
while waiting for locks. Note that if <varname>statement_timeout</>
is nonzero, it is rather pointless to set <varname>lock_timeout</> to
the same or larger value, since the statement timeout would always
trigger first.
</para>
<para>
Setting <varname>lock_timeout</> in
<filename>postgresql.conf</> is not recommended because it would
affect all sessions.
</para>
</listitem>
</varlistentry>