1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-03 20:02:46 +03:00

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
This commit is contained in:
Noah Misch
2021-06-14 17:29:37 -07:00
parent 0aac73e6a2
commit 5f1df62a45
6 changed files with 2 additions and 70 deletions

View File

@ -397,11 +397,6 @@ CREATE OR REPLACE FUNCTION
RETURNS boolean STRICT VOLATILE LANGUAGE INTERNAL AS 'pg_terminate_backend'
PARALLEL SAFE;
CREATE OR REPLACE FUNCTION
pg_wait_for_backend_termination(pid integer, timeout int8 DEFAULT 5000)
RETURNS boolean STRICT VOLATILE LANGUAGE INTERNAL AS 'pg_wait_for_backend_termination'
PARALLEL SAFE;
-- legacy definition for compatibility with 9.3
CREATE OR REPLACE FUNCTION
json_populate_record(base anyelement, from_json json, use_json_as_text boolean DEFAULT false)

View File

@ -230,42 +230,6 @@ pg_terminate_backend(PG_FUNCTION_ARGS)
PG_RETURN_BOOL(r == SIGNAL_BACKEND_SUCCESS);
}
/*
* Wait for a backend process with the given PID to exit or until the given
* timeout milliseconds occurs. Returns true if the backend has exited. On
* timeout a warning is emitted and false is returned.
*
* We allow any user to call this function, consistent with any user being
* able to view the pid of the process in pg_stat_activity etc.
*/
Datum
pg_wait_for_backend_termination(PG_FUNCTION_ARGS)
{
int pid;
int64 timeout;
PGPROC *proc = NULL;
pid = PG_GETARG_INT32(0);
timeout = PG_GETARG_INT64(1);
if (timeout <= 0)
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("\"timeout\" must not be negative or zero")));
proc = BackendPidGetProc(pid);
if (proc == NULL)
{
ereport(WARNING,
(errmsg("PID %d is not a PostgreSQL server process", pid)));
PG_RETURN_BOOL(false);
}
PG_RETURN_BOOL(pg_wait_until_termination(pid, timeout));
}
/*
* Signal to reload the database configuration
*

View File

@ -53,6 +53,6 @@
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 202106101
#define CATALOG_VERSION_NO 202106151
#endif

View File

@ -6190,10 +6190,6 @@
proname => 'pg_terminate_backend', provolatile => 'v', prorettype => 'bool',
proargtypes => 'int4 int8', proargnames => '{pid,timeout}',
prosrc => 'pg_terminate_backend' },
{ oid => '2137', descr => 'wait for a backend process exit or timeout occurs',
proname => 'pg_wait_for_backend_termination', provolatile => 'v',
prorettype => 'bool', proargtypes => 'int4 int8',
proargnames => '{pid,timeout}', prosrc => 'pg_wait_for_backend_termination' },
{ oid => '2172', descr => 'prepare for taking an online backup',
proname => 'pg_start_backup', provolatile => 'v', proparallel => 'r',
prorettype => 'pg_lsn', proargtypes => 'text bool bool',