]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Use proc_exit() for walreceiver exit in WalRcvWaitForStartPosition()
authorFujii Masao <fujii@postgresql.org>
Thu, 16 Apr 2026 03:33:17 +0000 (12:33 +0900)
committerFujii Masao <fujii@postgresql.org>
Thu, 16 Apr 2026 03:33:17 +0000 (12:33 +0900)
Previously, when the walreceiver exited from WalRcvWaitForStartPosition()
at the startup process's request, it called exit(1) directly. This could
skip cleanup performed by the callback functions.

This commit makes the walreceiver to use proc_exit() instead, ensuring
normal cleanup is executed on exit.

Also this commit updates comments describing walreceiver termination.

Apply to master only, as this has not caused practical issues so far.

Author: Chao Li <lic@highgo.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Andreas Karlsson <andreas@proxel.se>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://postgr.es/m/74381238-4E8A-4621-B794-57025DCCE0BA@gmail.com

src/backend/replication/walreceiver.c

index 6da5b86dbc5f311db608b809042235be661bf98e..5ee6431091e1d12f731b5f23297eb1ef59b19b55 100644 (file)
@@ -30,9 +30,9 @@
  * a new one.
  *
  * Normal termination is by SIGTERM, which instructs the walreceiver to
- * exit(0). Emergency termination is by SIGQUIT; like any postmaster child
- * process, the walreceiver will simply abort and exit on SIGQUIT. A close
- * of the connection and a FATAL error are treated not as a crash but as
+ * ereport(FATAL). Emergency termination is by SIGQUIT; like any postmaster
+ * child process, the walreceiver will simply abort and exit on SIGQUIT. A
+ * close of the connection and a FATAL error are treated not as a crash but as
  * normal operation.
  *
  * This file contains the server-facing parts of walreceiver. The libpq-
@@ -710,7 +710,7 @@ WalRcvWaitForStartPosition(XLogRecPtr *startpoint, TimeLineID *startpointTLI)
                         * to die, but might as well check it here too.
                         */
                        SpinLockRelease(&walrcv->mutex);
-                       exit(1);
+                       proc_exit(1);
                }
                SpinLockRelease(&walrcv->mutex);