Fix for early log messages during postmaster startup getting lost when
authorMagnus Hagander <[email protected]>
Sun, 11 Feb 2007 15:12:21 +0000 (15:12 +0000)
committerMagnus Hagander <[email protected]>
Sun, 11 Feb 2007 15:12:21 +0000 (15:12 +0000)
running as a service on Win32.

Per report from Harald Armin Massa.

Backpatch to 8.2.

src/backend/postmaster/postmaster.c
src/backend/utils/error/elog.c

index dd00cd69ab8ebf06c6e326120c31a3ae9f839171..4b175dfc680415db7bf5bd45313ea1b8ba933c12 100644 (file)
@@ -202,8 +202,8 @@ static pid_t StartupPID = 0,
                        BgWriterPID = 0,
                        AutoVacPID = 0,
                        PgArchPID = 0,
-                       PgStatPID = 0,
-                       SysLoggerPID = 0;
+                       PgStatPID = 0;
+pid_t                  SysLoggerPID = 0; /* Needs to be accessed from elog.c */
 
 /* Startup/shutdown state */
 #define                        NoShutdown              0
index 61b42b7cb88aaa8d9c2fafa6722c0627daf057b0..91898828bf5f2bf6ef0f4c8a040242f6bd485b31 100644 (file)
@@ -76,6 +76,8 @@ ErrorContextCallback *error_context_stack = NULL;
 
 sigjmp_buf *PG_exception_stack = NULL;
 
+extern pid_t SysLoggerPID;
+
 /* GUC parameters */
 PGErrorVerbosity Log_error_verbosity = PGERROR_VERBOSE;
 char      *Log_line_prefix = NULL;             /* format for extra log line info */
@@ -1715,9 +1717,10 @@ send_message_to_server_log(ErrorData *edata)
                 * anything going there and write it to the eventlog instead.
                 *
                 * If stderr redirection is active, it's ok to write to stderr because
-                * that's really a pipe to the syslogger process.
+                * that's really a pipe to the syslogger process. Unless we're in the
+                * postmaster, and the syslogger process isn't started yet.
                 */
-               if ((!Redirect_stderr || am_syslogger) && pgwin32_is_service())
+               if ((!Redirect_stderr || am_syslogger || (!IsUnderPostmaster && SysLoggerPID==0)) && pgwin32_is_service())
                        write_eventlog(edata->elevel, buf.data);
                else
 #endif