Skip to content

Commit 5f1df62

Browse files
committed
Remove pg_wait_for_backend_termination().
It was unable to wait on a backend that had already left the procarray. Users tolerant of that limitation can poll pg_stat_activity. Other users can employ the "timeout" argument of pg_terminate_backend(). Reviewed by Bharath Rupireddy. Discussion: https://postgr.es/m/20210605013236.GA208701@rfd.leadboat.com
1 parent 0aac73e commit 5f1df62

File tree

6 files changed

+2
-70
lines changed

6 files changed

+2
-70
lines changed

doc/src/sgml/func.sgml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25002,23 +25002,6 @@ SELECT collation for ('foo' COLLATE "de_DE");
2500225002
<literal>false</literal> is returned.
2500325003
</para></entry>
2500425004
</row>
25005-
25006-
<row>
25007-
<entry role="func_table_entry"><para role="func_signature">
25008-
<indexterm>
25009-
<primary>pg_wait_for_backend_termination</primary>
25010-
</indexterm>
25011-
<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> )
25012-
<returnvalue>boolean</returnvalue>
25013-
</para>
25014-
<para>
25015-
Waits for the backend process with the specified Process ID to
25016-
terminate. If the process terminates before
25017-
the <parameter>timeout</parameter> (in milliseconds)
25018-
expires, <literal>true</literal> is returned. On timeout, a warning
25019-
is emitted and <literal>false</literal> is returned.
25020-
</para></entry>
25021-
</row>
2502225005
</tbody>
2502325006
</tgroup>
2502425007
</table>

doc/src/sgml/release-14.sgml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -640,13 +640,7 @@ Author: Magnus Hagander <magnus@hagander.net>
640640
-->
641641

642642
<para>
643-
Add function <link
644-
linkend="functions-admin-signal"><function>pg_wait_for_backend_termination()</function></link>
645-
that waits for session exit (Bharath Rupireddy)
646-
</para>
647-
648-
<para>
649-
Also add a similar optional wait parameter to <link
643+
Add an optional timeout parameter to <link
650644
linkend="functions-admin-signal"><function>pg_terminate_backend()</function></link>
651645
</para>
652646
</listitem>

src/backend/catalog/system_functions.sql

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,6 @@ CREATE OR REPLACE FUNCTION
397397
RETURNS boolean STRICT VOLATILE LANGUAGE INTERNAL AS 'pg_terminate_backend'
398398
PARALLEL SAFE;
399399

400-
CREATE OR REPLACE FUNCTION
401-
pg_wait_for_backend_termination(pid integer, timeout int8 DEFAULT 5000)
402-
RETURNS boolean STRICT VOLATILE LANGUAGE INTERNAL AS 'pg_wait_for_backend_termination'
403-
PARALLEL SAFE;
404-
405400
-- legacy definition for compatibility with 9.3
406401
CREATE OR REPLACE FUNCTION
407402
json_populate_record(base anyelement, from_json json, use_json_as_text boolean DEFAULT false)

src/backend/storage/ipc/signalfuncs.c

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -230,42 +230,6 @@ pg_terminate_backend(PG_FUNCTION_ARGS)
230230
PG_RETURN_BOOL(r == SIGNAL_BACKEND_SUCCESS);
231231
}
232232

233-
/*
234-
* Wait for a backend process with the given PID to exit or until the given
235-
* timeout milliseconds occurs. Returns true if the backend has exited. On
236-
* timeout a warning is emitted and false is returned.
237-
*
238-
* We allow any user to call this function, consistent with any user being
239-
* able to view the pid of the process in pg_stat_activity etc.
240-
*/
241-
Datum
242-
pg_wait_for_backend_termination(PG_FUNCTION_ARGS)
243-
{
244-
int pid;
245-
int64 timeout;
246-
PGPROC *proc = NULL;
247-
248-
pid = PG_GETARG_INT32(0);
249-
timeout = PG_GETARG_INT64(1);
250-
251-
if (timeout <= 0)
252-
ereport(ERROR,
253-
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
254-
errmsg("\"timeout\" must not be negative or zero")));
255-
256-
proc = BackendPidGetProc(pid);
257-
258-
if (proc == NULL)
259-
{
260-
ereport(WARNING,
261-
(errmsg("PID %d is not a PostgreSQL server process", pid)));
262-
263-
PG_RETURN_BOOL(false);
264-
}
265-
266-
PG_RETURN_BOOL(pg_wait_until_termination(pid, timeout));
267-
}
268-
269233
/*
270234
* Signal to reload the database configuration
271235
*

src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 202106101
56+
#define CATALOG_VERSION_NO 202106151
5757

5858
#endif

src/include/catalog/pg_proc.dat

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6190,10 +6190,6 @@
61906190
proname => 'pg_terminate_backend', provolatile => 'v', prorettype => 'bool',
61916191
proargtypes => 'int4 int8', proargnames => '{pid,timeout}',
61926192
prosrc => 'pg_terminate_backend' },
6193-
{ oid => '2137', descr => 'wait for a backend process exit or timeout occurs',
6194-
proname => 'pg_wait_for_backend_termination', provolatile => 'v',
6195-
prorettype => 'bool', proargtypes => 'int4 int8',
6196-
proargnames => '{pid,timeout}', prosrc => 'pg_wait_for_backend_termination' },
61976193
{ oid => '2172', descr => 'prepare for taking an online backup',
61986194
proname => 'pg_start_backup', provolatile => 'v', proparallel => 'r',
61996195
prorettype => 'pg_lsn', proargtypes => 'text bool bool',

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy