You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by av...@apache.org on 2025/01/23 09:05:16 UTC

(cloudberry) 24/26: Remove obsolete check in SIGTERM handler for the startup process.

This is an automated email from the ASF dual-hosted git repository.

avamingli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit fe6c6d736b26c4e598cd93cf6492f28b5ea7e34e
Author: Nathan Bossart <na...@postgresql.org>
AuthorDate: Wed Feb 14 17:09:31 2024 -0600

    Remove obsolete check in SIGTERM handler for the startup process.
    
    Backported from 8fd0498de2005b4136aaf6fcd056ca4b18e37724 with minor
    conflicts. Original commit message follows:
    
    Thanks to commit 3b00fdba9f, this check in the SIGTERM handler for
    the startup process is now obsolete and can be removed.  Instead of
    leaving around the dead function write_stderr_signal_safe(), I've
    opted to just remove it for now.
    
    This partially reverts commit 97550c0711.
    
    Reviewed-by: Andres Freund, Noah Misch
    Discussion: https://postgr.es/m/20231121212008.GA3742740%40nathanxps13
    
    Reviewed-by: Huansong Fu <fu...@gmail.com>
    Reviewed-by: Brent Doil <bd...@vmware.com>
    Reviewed-by: Jimmy Yih <jy...@vmware.com>
---
 src/backend/postmaster/startup.c | 15 +--------------
 src/backend/utils/error/elog.c   | 28 ----------------------------
 src/include/utils/elog.h         |  5 -----
 3 files changed, 1 insertion(+), 47 deletions(-)

diff --git a/src/backend/postmaster/startup.c b/src/backend/postmaster/startup.c
index 4755db0efb..c8752b5cc7 100644
--- a/src/backend/postmaster/startup.c
+++ b/src/backend/postmaster/startup.c
@@ -103,20 +103,7 @@ StartupProcShutdownHandler(SIGNAL_ARGS)
 	int			save_errno = errno;
 
 	if (in_restore_command)
-	{
-		/*
-		 * If we are in a child process (e.g., forked by system() in
-		 * RestoreArchivedFile()), we don't want to call any exit callbacks.
-		 * The parent will take care of that.
-		 */
-		if (MyProcPid == (int) getpid())
-			proc_exit(1);
-		else
-		{
-			write_stderr_signal_safe("StartupProcShutdownHandler() called in child process\n");
-			_exit(1);
-		}
-	}
+		proc_exit(1);
 	else
 		shutdown_requested = true;
 	WakeupRecovery();
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index dfe0113a10..df632b8b91 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -5057,34 +5057,6 @@ write_stderr(const char *fmt,...)
 	va_end(ap);
 }
 
-/*
- * Write a message to STDERR using only async-signal-safe functions.  This can
- * be used to safely emit a message from a signal handler.
- *
- * TODO: It is likely possible to safely do a limited amount of string
- * interpolation (e.g., %s and %d), but that is not presently supported.
- */
-void
-write_stderr_signal_safe(const char *str)
-{
-	int			nwritten = 0;
-	int			ntotal = strlen(str);
-
-	while (nwritten < ntotal)
-	{
-		int			rc;
-
-		rc = write(STDERR_FILENO, str + nwritten, ntotal - nwritten);
-
-		/* Just give up on error.  There isn't much else we can do. */
-		if (rc == -1)
-			return;
-
-		nwritten += rc;
-	}
-}
-
-
 /*
  * Adjust the level of a recovery-related message per trace_recovery_messages.
  *
diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h
index 534d9f0bef..0f61a3ae8b 100644
--- a/src/include/utils/elog.h
+++ b/src/include/utils/elog.h
@@ -607,10 +607,5 @@ extern bool gp_log_stack_trace_lines;   /* session GUC, controls line info in st
 
 extern const char *SegvBusIllName(int signal);
 extern void StandardHandlerForSigillSigsegvSigbus_OnMainThread(char * processName, SIGNAL_ARGS);
-/*
- * Write a message to STDERR using only async-signal-safe functions.  This can
- * be used to safely emit a message from a signal handler.
- */
-extern void write_stderr_signal_safe(const char *fmt);
 
 #endif							/* ELOG_H */


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org