pg_wait_for_backend_termination-v1.patch
text/plain
Filename: pg_wait_for_backend_termination-v1.patch
Type: text/plain
Part: 0
Patch
Format: unified
Series: patch v1
| File | + | − |
|---|---|---|
| doc/src/sgml/func.sgml | 0 | 17 |
| doc/src/sgml/release-14.sgml | 1 | 7 |
| src/backend/catalog/system_functions.sql | 0 | 5 |
| src/backend/storage/ipc/signalfuncs.c | 0 | 36 |
| src/include/catalog/pg_proc.dat | 0 | 4 |
Author: Noah Misch <noah@leadboat.com>
Commit: Noah Misch <noah@leadboat.com>
Remove pg_wait_for_backend_termination().
It was unable 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 FIXME.
Discussion: https://postgr.es/m/20210605013236.GA208701@rfd.leadboat.com
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index fbc80c1..d387a32 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -25002,23 +25002,6 @@ SELECT collation for ('foo' COLLATE "de_DE");
<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>
</tgroup>
</table>
diff --git a/doc/src/sgml/release-14.sgml b/doc/src/sgml/release-14.sgml
index a2ad120..045f2b0 100644
--- a/doc/src/sgml/release-14.sgml
+++ b/doc/src/sgml/release-14.sgml
@@ -611,13 +611,7 @@ Author: Magnus Hagander <magnus@hagander.net>
-->
<para>
- Add function <link
- linkend="functions-admin-signal"><function>pg_wait_for_backend_termination()</function></link>
- that waits for session exit (Bharath Rupireddy)
- </para>
-
- <para>
- Also add a similar optional wait parameter to <link
+ Add an optional wait parameter to <link
linkend="functions-admin-signal"><function>pg_terminate_backend()</function></link>
</para>
</listitem>
diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index a4373b1..a416e94 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -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)
diff --git a/src/backend/storage/ipc/signalfuncs.c b/src/backend/storage/ipc/signalfuncs.c
index 8376994..5ed8b2e 100644
--- a/src/backend/storage/ipc/signalfuncs.c
+++ b/src/backend/storage/ipc/signalfuncs.c
@@ -231,42 +231,6 @@ pg_terminate_backend(PG_FUNCTION_ARGS)
}
/*
- * 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
*
* Permission checking for this function is managed through the normal
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index acbcae4..2d45765 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -6191,10 +6191,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',