mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Add functions to wait for backend termination
This adds a function, pg_wait_for_backend_termination(), and a new timeout argument to pg_terminate_backend(), which will wait for the backend to actually terminate (with or without signaling it to do so depending on which function is called). The default behaviour of pg_terminate_backend() remains being timeout=0 which does not waiting. For pg_wait_for_backend_termination() the default wait is 5 seconds. Author: Bharath Rupireddy Reviewed-By: Fujii Masao, David Johnston, Muhammad Usama, Hou Zhijie, Magnus Hagander Discussion: https://postgr.es/m/CALj2ACUBpunmyhYZw-kXCYs5NM+h6oG_7Df_Tn4mLmmUQifkqA@mail.gmail.com
This commit is contained in:
@@ -24977,7 +24977,7 @@ SELECT collation for ('foo' COLLATE "de_DE");
|
||||
<indexterm>
|
||||
<primary>pg_terminate_backend</primary>
|
||||
</indexterm>
|
||||
<function>pg_terminate_backend</function> ( <parameter>pid</parameter> <type>integer</type> )
|
||||
<function>pg_terminate_backend</function> ( <parameter>pid</parameter> <type>integer</type>, <parameter>timeout</parameter> <type>bigint</type> <literal>DEFAULT</literal> <literal>0</literal> )
|
||||
<returnvalue>boolean</returnvalue>
|
||||
</para>
|
||||
<para>
|
||||
@@ -24986,6 +24986,34 @@ SELECT collation for ('foo' COLLATE "de_DE");
|
||||
is a member of the role whose backend is being terminated or the
|
||||
calling role has been granted <literal>pg_signal_backend</literal>,
|
||||
however only superusers can terminate superuser backends.
|
||||
</para>
|
||||
<para>
|
||||
If <parameter>timeout</parameter> is not specified or zero, this
|
||||
function returns <literal>true</literal> whether the process actually
|
||||
terminates or not, indicating only that the sending of the signal was
|
||||
successful. If the <parameter>timeout</parameter> is specified (in
|
||||
milliseconds) and greater than zero, the function waits until the
|
||||
process is actually terminated or until the given time has passed. If
|
||||
the process is terminated, the function
|
||||
returns <literal>true</literal>. On timeout a warning is emitted and
|
||||
<literal>false</literal> is returned.
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="func_table_entry"><para role="func_signature">
|
||||
<indexterm>
|
||||
<primary>pg_wait_for_backend_termination</primary>
|
||||
</indexterm>
|
||||
<function>pg_wait_for_backend_termination</function> ( <parameter>pid</parameter> <type>integer</type>, <parameter>timeout</parameter> <type>bigint</type> <literal>DEFAULT</literal> <literal>5000</literal> )
|
||||
<returnvalue>boolean</returnvalue>
|
||||
</para>
|
||||
<para>
|
||||
Waits for the backend process with the specified Process ID to
|
||||
terminate. If the process terminates before
|
||||
the <parameter>timeout</parameter> (in milliseconds)
|
||||
expires, <literal>true</literal> is returned. On timeout, a warning
|
||||
is emitted and <literal>false</literal> is returned.
|
||||
</para></entry>
|
||||
</row>
|
||||
</tbody>
|
||||
|
@@ -1585,6 +1585,10 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
|
||||
<entry>Waiting for subplan nodes of an <literal>Append</literal> plan
|
||||
node to be ready.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>BackendTermination</literal></entry>
|
||||
<entry>Waiting for the termination of another backend.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>BackupWaitWalArchive</literal></entry>
|
||||
<entry>Waiting for WAL files required for a backup to be successfully
|
||||
|
Reference in New Issue
Block a user