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 1gPTln-0008Mx-U7 for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Nov 2018 14:46:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gPTlm-0004dw-Fg for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Nov 2018 14:46:22 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gPTlm-0004dp-5B for pgsql-hackers@lists.postgresql.org; Wed, 21 Nov 2018 14:46:22 +0000 Received: from gauss.credativ.com ([93.94.130.89]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gPTle-0004QH-BW for pgsql-hackers@postgresql.org; Wed, 21 Nov 2018 14:46:20 +0000 Received: from gauss.credativ.com (localhost [127.0.0.1]) by gauss.credativ.com (Postfix) with ESMTP id E76B01E3B40; Wed, 21 Nov 2018 15:46:11 +0100 (CET) Received: from msg.credativ.de (fw-front.credativ.com [62.154.226.94]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: cbe@gauss.credativ.com) by gauss.credativ.com (Postfix) with ESMTPSA id CFE2A1E3B3F for ; Wed, 21 Nov 2018 15:46:11 +0100 (CET) Date: Wed, 21 Nov 2018 15:46:11 +0100 From: Christoph Berg To: PostgreSQL Hackers Subject: [PATCH] Log PostgreSQL version number on startup Message-ID: <20181121144611.GJ15795@msg.credativ.de> Mail-Followup-To: Christoph Berg , PostgreSQL Hackers MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ADZbWkCsHQ7r3kzd" Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --ADZbWkCsHQ7r3kzd Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hi, it has bugged me for a long time that there's no clear "PostgreSQL is starting" message in the server log file. I'd like to change that for two reasons: * when reading a long log file, it's not entirely clear where a new server startup begins. It was worse in the past (first message was "database system was shut down at..." which rather looks like a shutdown message to newbie users), now it's "listening on IPv6..." but that message might possibly become DEBUG1, or listen_addresses might become changeable at run-time * while upgrading servers, it's useful to know which server version was actually started if there are several startup attempts The change would be to log "Starting PG_VERSION_STR" as early as possible. 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.) Christoph -- Senior Berater, Tel.: +49 2166 9901 187 credativ GmbH, HRB Mönchengladbach 12080, USt-ID-Nummer: DE204566209 Trompeterallee 108, 41189 Mönchengladbach Geschäftsführung: Dr. Michael Meskes, Jörg Folz, Sascha Heuer Unser Umgang mit personenbezogenen Daten unterliegt folgenden Bestimmungen: https://www.credativ.de/datenschutz --ADZbWkCsHQ7r3kzd Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Log-PostgreSQL-version-number-on-startup.patch" From 49f786a26110ca55d12c47f75e8662047e78c5c8 Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Wed, 21 Nov 2018 15:43:34 +0100 Subject: [PATCH] Log PostgreSQL version number on startup Logging the PostgreSQL version on startup is useful for two reasons: There is a clear marker in the log file that a new postmaster is beginning, and it's useful for tracking the server version across startup while upgrading. --- src/backend/postmaster/postmaster.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index a33a131182..e0abfd686a 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -1306,6 +1306,10 @@ PostmasterMain(int argc, char *argv[]) whereToSendOutput = DestNone; + /* Report server startup in log */ + ereport(LOG, + (errmsg("starting %s", PG_VERSION_STR))); + /* * Initialize stats collection subsystem (this does NOT start the * collector process!) -- 2.19.1 --ADZbWkCsHQ7r3kzd--