Re: A new function to wait for the backend exit after termination

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, "Hou, Zhijie" <houzj(dot)fnst(at)cn(dot)fujitsu(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Muhammad Usama <m(dot)usama(at)gmail(dot)com>
Subject: Re: A new function to wait for the backend exit after termination
Date: 2021-06-12 18:27:43
Message-ID: 20210612182743.GY16435@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Jun 12, 2021 at 08:21:39AM -0700, Noah Misch wrote:
> On Sat, Jun 12, 2021 at 12:12:12AM -0500, Justin Pryzby wrote:
> > Even if it's not removed, the descriptions should be cleaned up.
> >
> > | src/include/catalog/pg_proc.dat- descr => 'terminate a backend process and if timeout is specified, wait for its exit or until timeout occurs',
> > => I think doesn't need to change or mention the optional timeout at all
>
> Agreed, these strings generally give less detail. I can revert that to the
> v13 wording, 'terminate a server process'.

Maybe you'd also update the release notes.

I suggest some edits from the remaining parts of the original patch.

diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index fbc80c1403..b7383bc8aa 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -24998,7 +24998,7 @@ SELECT collation for ('foo' COLLATE "de_DE");
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
+ returns <literal>true</literal>. On timeout, a warning is emitted and
<literal>false</literal> is returned.
</para></entry>
</row>
diff --git a/src/backend/storage/ipc/signalfuncs.c b/src/backend/storage/ipc/signalfuncs.c
index 837699481c..f12c417854 100644
--- a/src/backend/storage/ipc/signalfuncs.c
+++ b/src/backend/storage/ipc/signalfuncs.c
@@ -187,12 +187,12 @@ pg_wait_until_termination(int pid, int64 timeout)
}

/*
- * Signal to terminate a backend process. This is allowed if you are a member
- * of the role whose process is being terminated. If timeout input argument is
- * 0 (which is default), then this function just signals the backend and
- * doesn't wait. Otherwise it waits until given the timeout milliseconds or no
- * process has the given PID and returns true. On timeout, a warning is emitted
- * and false is returned.
+ * Send a signal to terminate a backend process. This is allowed if you are a
+ * member of the role whose process is being terminated. If the timeout input
+ * argument is 0, then this function just signals the backend and returns true.
+ * If timeout is nonzero, then it waits until no process has the given PID; if
+ * the process ends within the timeout, true is returned, and if the timeout is
+ * exceeded, a warning is emitted and false is returned.
*
* Note that only superusers can signal superuser-owned processes.
*/
@@ -201,7 +201,7 @@ pg_terminate_backend(PG_FUNCTION_ARGS)
{
int pid;
int r;
- int timeout;
+ int timeout; /* milliseconds */

pid = PG_GETARG_INT32(0);
timeout = PG_GETARG_INT64(1);

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2021-06-12 18:43:08 Re: logical replication of truncate command with trigger causes Assert
Previous Message Yugo NAGATA 2021-06-12 18:27:42 Re: Error on pgbench logs