]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Only show signal-sender PID/UID detail in server log
authorAndrew Dunstan <andrew@dunslane.net>
Fri, 1 May 2026 15:52:14 +0000 (11:52 -0400)
committerAndrew Dunstan <andrew@dunslane.net>
Fri, 1 May 2026 17:20:08 +0000 (13:20 -0400)
The errdetail() added in 55890a91945 (and reworked in 3e2a1496bae)
exposed the operating-system PID and UID of whoever sent the
termination signal directly to the affected client.

Discussion suggested this should not be sent to the client, but only
recorded in the server log where the admin can use it for diagnosis.

Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Jakub Wartak <jakub.wartak@enterprisedb.com>
Discussion: https://postgr.es/m/E5CA274C-74BD-4067-8B73-A3AD8C080EFA@gmail.com

src/backend/replication/syncrep.c
src/backend/tcop/postgres.c
src/bin/psql/t/001_basic.pl

index 73450fe437e22257f76418c04fae345a96a69f42..e0e30579c590224b54abc5fff211316262423414 100644 (file)
@@ -304,9 +304,10 @@ SyncRepWaitForLSN(XLogRecPtr lsn, bool commit)
                                ereport(WARNING,
                                                (errcode(ERRCODE_ADMIN_SHUTDOWN),
                                                 errmsg("canceling the wait for synchronous replication and terminating connection due to administrator command"),
-                                                errdetail("The transaction has already committed locally, but might not have been replicated to the standby.  Signal sent by PID %d, UID %d.",
-                                                                  (int) ProcDieSenderPid,
-                                                                  (int) ProcDieSenderUid)));
+                                                errdetail("The transaction has already committed locally, but might not have been replicated to the standby."),
+                                                errdetail_log("The transaction has already committed locally, but might not have been replicated to the standby.  Signal sent by PID %d, UID %d.",
+                                                                          (int) ProcDieSenderPid,
+                                                                          (int) ProcDieSenderUid)));
                        else
                                ereport(WARNING,
                                                (errcode(ERRCODE_ADMIN_SHUTDOWN),
index 2c1f14b78891a777052441fe356423c29a2ab170..dbef734a93f15420f772e7fc1e0506d0576315c6 100644 (file)
@@ -111,12 +111,13 @@ int                       client_connection_check_interval = 0;
 int                    restrict_nonsystem_relation_kind;
 
 /*
- * Include signal sender PID/UID as errdetail when available (SA_SIGINFO).
- * The caller must supply the (already-captured) pid and uid values.
+ * Include signal sender PID/UID in the server log when available
+ * (SA_SIGINFO). The caller must supply the already-captured pid and uid
+ * values.
  */
 #define ERRDETAIL_SIGNAL_SENDER(pid, uid) \
        ((pid) == 0 ? 0 : \
-        errdetail("Signal sent by PID %d, UID %d.", (int) (pid), (int) (uid)))
+        errdetail_log("Signal sent by PID %d, UID %d.", (int) (pid), (int) (uid)))
 
 /* ----------------
  *             private typedefs etc
index 7c21204c1f2f8d800a25300cbed63bc239e4fc35..cd4a21ca6391a54e518cdb7233741f759bd1e9ee 100644 (file)
@@ -143,7 +143,7 @@ is($ret, 2, 'server crash: psql exit code');
 like($out, qr/before/, 'server crash: output before crash');
 unlike($out, qr/AFTER/, 'server crash: no output after crash');
 like( $err, qr/psql:<stdin>:2: FATAL:  terminating connection due to administrator command
-(?:DETAIL:  Signal sent by PID \d+, UID \d+\.\n)?psql:<stdin>:2: server closed the connection unexpectedly
+psql:<stdin>:2: server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
 psql:<stdin>:2: error: connection to server was lost/,