Remove pg_wait_for_backend_termination().
authorNoah Misch
Tue, 15 Jun 2021 00:29:37 +0000 (17:29 -0700)
committerNoah Misch
Tue, 15 Jun 2021 00:29:37 +0000 (17:29 -0700)
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[email protected]

doc/src/sgml/func.sgml
doc/src/sgml/release-14.sgml
src/backend/catalog/system_functions.sql
src/backend/storage/ipc/signalfuncs.c
src/include/catalog/catversion.h
src/include/catalog/pg_proc.dat

index b7383bc8aa218c43c73eddb05e0db3b2acb4f8a9..764c3ad30711a12216bfa235a6b6caf05f0b4480 100644 (file)
@@ -25002,23 +25002,6 @@ SELECT collation for ('foo' COLLATE "de_DE");
         false is returned.
        
       
-
-      
-       
-        
-         pg_wait_for_backend_termination
-        
-        pg_wait_for_backend_termination ( pid integertimeout bigint DEFAULT 5000 )
-        boolean
-       
-       
-        Waits for the backend process with the specified Process ID to
-        terminate.  If the process terminates before
-        the timeout (in milliseconds)
-        expires, true is returned.  On timeout, a warning
-        is emitted and false is returned.
-       
-      
      
     
    
index a291f9301729d332d16df339ef7281ec34e5d645..53221ab8c10bddc618d5359e5ea2a709dda8ef67 100644 (file)
@@ -640,13 +640,7 @@ Author: Magnus Hagander 
 -->
 
       
-       Add function 
-       linkend="functions-admin-signal">pg_wait_for_backend_termination()
-       that waits for session exit (Bharath Rupireddy)
-      
-
-      
-       Also add a similar optional wait parameter to 
+       Add an optional timeout parameter to 
        linkend="functions-admin-signal">pg_terminate_backend()
       
      
index a4373b176c621a7f10d4a9225f41ece8d9afadf1..a416e94d3717a873e2d33a23ed2a72a78ddf204a 100644 (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)
index 0a111ad6daa983e8b95cf6f6f3f84a3388a73387..43386c5bb327422c7ebfac7bb84433411d2ab61d 100644 (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
  *
index d5dada949c33436238d0c7f7c7404d0cf0caa819..1b23c7c253bcb11daf9bf2586995b5e89e5f8cca 100644 (file)
@@ -53,6 +53,6 @@
  */
 
 /*                         yyyymmddN */
-#define CATALOG_VERSION_NO 202106101
+#define CATALOG_VERSION_NO 202106151
 
 #endif
index 83eea85cf64a5dcc15ee7379cdf779e1abae3cba..fde251fa4f3e1445686d74dd596950c90294a539 100644 (file)
   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',