[PATCH] Log PostgreSQL version number on startup

Lists: pgsql-hackers
From: Christoph Berg <christoph(dot)berg(at)credativ(dot)de>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: [PATCH] Log PostgreSQL version number on startup
Date: 2018-11-21 14:46:11
Message-ID: 20181121144611.GJ15795@msg.credativ.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

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

Attachment Content-Type Size
0001-Log-PostgreSQL-version-number-on-startup.patch text/x-diff 1.0 KB

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Christoph Berg <christoph(dot)berg(at)credativ(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Log PostgreSQL version number on startup
Date: 2018-11-21 16:32:46
Message-ID: 20181121163246.GR3415@tamriel.snowman.net
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Greetings,

* Christoph Berg (christoph(dot)berg(at)credativ(dot)de) wrote:
> 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:

+1

> * 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.)

I wonder if maybe we should do both (though with an appropriate "logs
now being logged through the logging collector" or some such).

I've not really looked at the patch at all, but definitely like the
idea.

Thanks!

Stephen


From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Christoph Berg <christoph(dot)berg(at)credativ(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Log PostgreSQL version number on startup
Date: 2018-12-10 06:33:07
Message-ID: 20181210063307.GD1105@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Nov 21, 2018 at 11:32:46AM -0500, Stephen Frost wrote:
> * Christoph Berg (christoph(dot)berg(at)credativ(dot)de) wrote:
>> 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:
>
> +1

+1. One complain which could be formulated is that this makes the
logs at startup more noisy. Now your patch has an issue if you want to
ensure that this information gets added to the log files, because at
this stage of startup the GUCs are not loaded, hence this is sent to
stderr, and perhaps not on the log files.
--
Michael


From: Christoph Berg <christoph(dot)berg(at)credativ(dot)de>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Log PostgreSQL version number on startup
Date: 2018-12-10 09:57:39
Message-ID: 20181210095739.GB13629@msg.credativ.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Re: Michael Paquier 2018-12-10 <20181210063307(dot)GD1105(at)paquier(dot)xyz>
> On Wed, Nov 21, 2018 at 11:32:46AM -0500, Stephen Frost wrote:
> > * Christoph Berg (christoph(dot)berg(at)credativ(dot)de) wrote:
> >> 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:
> >
> > +1
>
> +1. One complain which could be formulated is that this makes the
> logs at startup more noisy. Now your patch has an issue if you want to
> ensure that this information gets added to the log files, because at
> this stage of startup the GUCs are not loaded, hence this is sent to
> stderr, and perhaps not on the log files.

I placed it so that it gets logged after logging_collector is active.

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


From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Christoph Berg <christoph(dot)berg(at)credativ(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Log PostgreSQL version number on startup
Date: 2019-01-02 21:10:14
Message-ID: 11bcc510-cb63-5e1f-b994-72ad6afbfee5@2ndquadrant.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 21/11/2018 15:46, Christoph Berg wrote:
> 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

Do we want to do the whole version string, or just "PostgreSQL 12devel"?

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: Christoph Berg <christoph(dot)berg(at)credativ(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Log PostgreSQL version number on startup
Date: 2019-01-04 23:54:51
Message-ID: 20190104235451.GL2528@tamriel.snowman.net
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Greetings,

* Peter Eisentraut (peter(dot)eisentraut(at)2ndquadrant(dot)com) wrote:
> On 21/11/2018 15:46, Christoph Berg wrote:
> > 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
>
> Do we want to do the whole version string, or just "PostgreSQL 12devel"?

The whole thing.

Thanks!

Stephen


From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Christoph Berg <christoph(dot)berg(at)credativ(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Log PostgreSQL version number on startup
Date: 2019-01-05 01:12:30
Message-ID: 20190105011230.GB4849@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Jan 04, 2019 at 06:54:51PM -0500, Stephen Frost wrote:
> * Peter Eisentraut (peter(dot)eisentraut(at)2ndquadrant(dot)com) wrote:
>> Do we want to do the whole version string, or just "PostgreSQL 12devel"?
>
> The whole thing.

I would prefer the whole string as well, as that's useful to look
after all the details not only related to a given minor version, like
a build tagged with an internal compilation system number added with
configure's extra-version.
--
Michael


From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Christoph Berg <christoph(dot)berg(at)credativ(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Log PostgreSQL version number on startup
Date: 2019-01-05 14:53:31
Message-ID: d5d50936-20b9-85f1-06bc-94a01c5040c1@2ndquadrant.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

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?

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Christoph Berg <christoph(dot)berg(at)credativ(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Log PostgreSQL version number on startup
Date: 2019-01-16 19:58:48
Message-ID: 92bfdfdf-4164-aec5-4e32-c26e67821c38@2ndquadrant.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

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

Attachment Content-Type Size
0001-postmaster-Start-syslogger-earlier.patch text/plain 5.6 KB

From: Christoph Berg <christoph(dot)berg(at)credativ(dot)de>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Log PostgreSQL version number on startup
Date: 2019-01-29 15:46:06
Message-ID: 20190129154605.GJ9860@msg.credativ.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Re: Peter Eisentraut 2019-01-16 <92bfdfdf-4164-aec5-4e32-c26e67821c38(at)2ndquadrant(dot)com>
> > 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.

This works nicely, so +1.

I'm attaching your patch as 0001 and my rebased one on top of it as
0002.

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

Attachment Content-Type Size
0001-postmaster-Start-syslogger-earlier.patch text/x-diff 5.6 KB
0002-Log-PostgreSQL-version-number-on-startup.patch text/x-diff 988 bytes

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Christoph Berg <christoph(dot)berg(at)credativ(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Log PostgreSQL version number on startup
Date: 2019-01-30 22:29:41
Message-ID: 7490cb77-7e38-ccb2-d862-3c94408236fc@2ndquadrant.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 29/01/2019 16:46, Christoph Berg wrote:
> Re: Peter Eisentraut 2019-01-16 <92bfdfdf-4164-aec5-4e32-c26e67821c38(at)2ndquadrant(dot)com>
>>> 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.
>
> This works nicely, so +1.
>
> I'm attaching your patch as 0001 and my rebased one on top of it as
> 0002.

committed

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services