Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gjrOp-0000i8-SP for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Jan 2019 20:02:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gjrL2-00047D-GN for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Jan 2019 19:59:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gjrL2-000475-7r for pgsql-hackers@lists.postgresql.org; Wed, 16 Jan 2019 19:59:00 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gjrKx-000153-Uu for pgsql-hackers@postgresql.org; Wed, 16 Jan 2019 19:58:59 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 801C1235AE; Wed, 16 Jan 2019 14:58:51 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Wed, 16 Jan 2019 14:58:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=qrCMg8 kDSD9b2YNGNUskADjn0d8gSk+zxXx2OkqOzfA=; b=j3zBbp+/afCnWL5VT9IIiz yIeF80C3kraBOHiNrlOn6nvD+h7HJ+tI9LyDStlaPGw00aIGpGymQ+aW2S4kxXP3 gi7aHFWI5SYu88d+gSFG7oD1DImEICp/6E3aV4MPpI0jmMkEu3DZ3JP1z+j4JkQV WrhkWudHou8oF8ZsDS9+U+HsZXvErtiVwJS+O5zNL8i7u/jkaejeb4sydr6EJxX6 R27c6c4+/kyo3zWEi0zCqVjVAzE96QrtBFZi6sFiXAbBh6uitdKt2y9tDbX3roxQ +CfuqbnbQAyChUB+8o2c96HPr7hpzupWczH1xCFckIXXQvd9Q9jqIWeRryMcqmCQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrgeehgddufeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfquhhtnecuuegrihhlohhuthemucef tddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefuhffvfhhokf fffgggjggtsehmtderredtfeehnecuhfhrohhmpefrvghtvghrucfgihhsvghnthhrrghu thcuoehpvghtvghrrdgvihhsvghnthhrrghuthesvdhnughquhgrughrrghnthdrtghomh eqnecuffhomhgrihhnpedvnhguqhhurggurhgrnhhtrdgtohhmnecukfhppeelfedrvdeg fedrkeefrddvvdenucfrrghrrghmpehmrghilhhfrhhomhepphgvthgvrhdrvghishgvnh htrhgruhhtsedvnhguqhhurggurhgrnhhtrdgtohhmnecuvehluhhsthgvrhfuihiivgep td X-ME-Proxy: Received: from april.pezone.net (p5df35316.dip0.t-ipconnect.de [93.243.83.22]) by mail.messagingengine.com (Postfix) with ESMTPA id CC33C100BA; Wed, 16 Jan 2019 14:58:49 -0500 (EST) Subject: Re: [PATCH] Log PostgreSQL version number on startup From: Peter Eisentraut To: Christoph Berg , PostgreSQL Hackers References: <20181121144611.GJ15795@msg.credativ.de> Openpgp: preference=signencrypt Autocrypt: addr=peter.eisentraut@2ndquadrant.com; prefer-encrypt=mutual; keydata= xsFNBFUUt6kBEADZd9NNTBJbHmAXXJgPGOdd6Q73l80oifIVgn2tRxP9dYkCfTlo/yLqbKTl JNqTcyM6XrJDnB2sMEUGYCewYZXl+9C4bBJWyNqcEI1ae9u71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HJhAAxmSTsC5y7p9Zu+nnLpucv/h88oEx985e qWeXzQiwM3pfRZS+PdTH9TyzHK0KOgKoAiubk0vt+BrT91D9d0G5kVQaTctAErGBoMkTaZJT XVEcNphiPzysdSqvprjojMp1y7rG8AP+Xd6m0rE1LRnkRRm8HyI8vdXsuLQPITGWXDLMjaNq AOV3BUnzkgtjMuIYw7SCr+12ZOb5dEKvaG4kjC4kaJ/TLbuBhVANcXkC90yp0AOZLs/cB1Dj OAXno/RUUruJ3r27a+pFv768UAi9QWcdw58yPxreMNMLqAgsS9oTHwHfGNWcB2dJ4UW+GMLJ hTf9TjQ2f+N/sIx5XMQ9pYw6CAJMK29qPx6/ZayrPxf22EXf0D3zTwIEZgwfSkynFVwV25L7 awQq60fifdMYheSxq7GbhpsixmcD+e161cCmLIt75YDt5bQ0B1yf7EmxG8n7pGZAOM6LoNsU fkSldba5XVwh8LuN5mK0nQBELGW6Os4TDq4REggLpfcvFC215zpuo0iCGnmE/Bns4nowqUSP u4tkWL+nxW4qgv8wo8HJ52jd79EJ8iqfIBoidBfy9AIUiEUApGQzWPu6yWcI8fY0rN5D+tc+ Yw1Zt6Mm+huYJpgCRsTcfzEcahnBn521CWcWvhW1ff3KFileFMtNmnBBhMncmRKHphtTKEpN 3jI= Organization: 2ndQuadrant Message-ID: <92bfdfdf-4164-aec5-4e32-c26e67821c38@2ndquadrant.com> Date: Wed, 16 Jan 2019 20:58:48 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------67C6EBB3000527E5D39CEFC3" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------67C6EBB3000527E5D39CEFC3 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 05/01/2019 15:53, Peter Eisentraut wrote: > On 21/11/2018 15:46, Christoph Berg wrote: >> A startup looks like this: >> >> 2018-11-21 15:19:47.259 CET [24453] LOG: listening on IPv6 address "::1", port 5431 >> 2018-11-21 15:19:47.259 CET [24453] LOG: listening on IPv4 address "127.0.0.1", port 5431 >> 2018-11-21 15:19:47.315 CET [24453] LOG: listening on Unix socket "/tmp/.s.PGSQL.5431" >> 2018-11-21 15:19:47.394 CET [24453] LOG: starting PostgreSQL 12devel on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.2.0-9) 8.2.0, 64-bit >> 2018-11-21 15:19:47.426 CET [24454] LOG: database system was shut down at 2018-11-21 15:15:35 CET >> 2018-11-21 15:19:47.460 CET [24453] LOG: database system is ready to accept connections >> >> (I'd rather put the start message before the listening messages, but I >> think the startup message should be logged via logging_collector, and >> listening is logged before the log file is opened.) > > Why don't we start the logging collector before opening the sockets? Specifically, something like the attached. This keeps the dynamic module loading before the logging collector start, so we see those error messages on stderr, but then the setting up of the sockets would get logged. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --------------67C6EBB3000527E5D39CEFC3 Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="0001-postmaster-Start-syslogger-earlier.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-postmaster-Start-syslogger-earlier.patch" From 0a482552d26488ec5ce8e4d7bad12bf25ba44c8b Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 16 Jan 2019 17:32:01 +0100 Subject: [PATCH] postmaster: Start syslogger earlier XXX --- src/backend/postmaster/postmaster.c | 120 ++++++++++++++-------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index a707d4d465..36efd908bb 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -992,6 +992,66 @@ PostmasterMain(int argc, char *argv[]) */ InitializeMaxBackends(); + /* + * Initialize pipe (or process handle on Windows) that allows children to + * wake up from sleep on postmaster death. + */ + InitPostmasterDeathWatchHandle(); + + /* + * Forcibly remove the files signaling a standby promotion request. + * Otherwise, the existence of those files triggers a promotion too early, + * whether a user wants that or not. + * + * This removal of files is usually unnecessary because they can exist + * only during a few moments during a standby promotion. However there is + * a race condition: if pg_ctl promote is executed and creates the files + * during a promotion, the files can stay around even after the server is + * brought up to new master. Then, if new standby starts by using the + * backup taken from that master, the files can exist at the server + * startup and should be removed in order to avoid an unexpected + * promotion. + * + * Note that promotion signal files need to be removed before the startup + * process is invoked. Because, after that, they can be used by + * postmaster's SIGUSR1 signal handler. + */ + RemovePromoteSignalFiles(); + + /* Do the same for logrotate signal file */ + RemoveLogrotateSignalFiles(); + + /* Remove any outdated file holding the current log filenames. */ + if (unlink(LOG_METAINFO_DATAFILE) < 0 && errno != ENOENT) + ereport(LOG, + (errcode_for_file_access(), + errmsg("could not remove file \"%s\": %m", + LOG_METAINFO_DATAFILE))); + + /* + * If enabled, start up syslogger collection subprocess + */ + SysLoggerPID = SysLogger_Start(); + + /* + * Reset whereToSendOutput from DestDebug (its starting state) to + * DestNone. This stops ereport from sending log messages to stderr unless + * Log_destination permits. We don't do this until the postmaster is + * fully launched, since startup failures may as well be reported to + * stderr. + * + * If we are in fact disabling logging to stderr, first emit a log message + * saying so, to provide a breadcrumb trail for users who may not remember + * that their logging is configured to go somewhere else. + */ + if (!(Log_destination & LOG_DESTINATION_STDERR)) + ereport(LOG, + (errmsg("ending log output to stderr"), + errhint("Future log output will go to log destination \"%s\".", + Log_destination_string))); + + whereToSendOutput = DestNone; + /* * Establish input sockets. * @@ -1183,12 +1243,6 @@ PostmasterMain(int argc, char *argv[]) */ set_stack_base(); - /* - * Initialize pipe (or process handle on Windows) that allows children to - * wake up from sleep on postmaster death. - */ - InitPostmasterDeathWatchHandle(); - #ifdef WIN32 /* @@ -1242,60 +1296,6 @@ PostmasterMain(int argc, char *argv[]) */ RemovePgTempFiles(); - /* - * Forcibly remove the files signaling a standby promotion request. - * Otherwise, the existence of those files triggers a promotion too early, - * whether a user wants that or not. - * - * This removal of files is usually unnecessary because they can exist - * only during a few moments during a standby promotion. However there is - * a race condition: if pg_ctl promote is executed and creates the files - * during a promotion, the files can stay around even after the server is - * brought up to new master. Then, if new standby starts by using the - * backup taken from that master, the files can exist at the server - * startup and should be removed in order to avoid an unexpected - * promotion. - * - * Note that promotion signal files need to be removed before the startup - * process is invoked. Because, after that, they can be used by - * postmaster's SIGUSR1 signal handler. - */ - RemovePromoteSignalFiles(); - - /* Do the same for logrotate signal file */ - RemoveLogrotateSignalFiles(); - - /* Remove any outdated file holding the current log filenames. */ - if (unlink(LOG_METAINFO_DATAFILE) < 0 && errno != ENOENT) - ereport(LOG, - (errcode_for_file_access(), - errmsg("could not remove file \"%s\": %m", - LOG_METAINFO_DATAFILE))); - - /* - * If enabled, start up syslogger collection subprocess - */ - SysLoggerPID = SysLogger_Start(); - - /* - * Reset whereToSendOutput from DestDebug (its starting state) to - * DestNone. This stops ereport from sending log messages to stderr unless - * Log_destination permits. We don't do this until the postmaster is - * fully launched, since startup failures may as well be reported to - * stderr. - * - * If we are in fact disabling logging to stderr, first emit a log message - * saying so, to provide a breadcrumb trail for users who may not remember - * that their logging is configured to go somewhere else. - */ - if (!(Log_destination & LOG_DESTINATION_STDERR)) - ereport(LOG, - (errmsg("ending log output to stderr"), - errhint("Future log output will go to log destination \"%s\".", - Log_destination_string))); - - whereToSendOutput = DestNone; - /* * Initialize stats collection subsystem (this does NOT start the * collector process!) -- 2.20.1 --------------67C6EBB3000527E5D39CEFC3--