Re: Moving responsibility for logging "database system is shut down"

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Moving responsibility for logging "database system is shut down"
Date: 2016-02-10 21:07:39
Message-ID: CA+Tgmob65aKdARKSEfmZ9e7Q=pPpcMu4ts6RVF0pzPeib3=b8A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Feb 10, 2016 at 3:13 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> In our recent investigations of slow shutdown on some buildfarm members,
> it became clear that "database system is shut down" can get logged many
> seconds before the postmaster actually exits; the main cause of delay
> is that the stats collector's final data dump can take awhile. This is
> pretty confusing, IMO. I think that that message should only come out
> once the postmaster has removed its pidfile, which is the action that
> makes it look shut-down to "pg_ctl stop".
>
> After some investigation it seems that the best place to do the logging
> is right in UnlinkLockFiles(); that's called when and only when we need
> a log message, and there doesn't seem to be a better place for it.
> I considered putting the logging into proc_exit(), but then we would need
> more logic to determine whether the type of process we're exiting is one
> for which such a message should be printed. That seems messier.
>
> I also considered moving the "shutting down" message that is currently
> printed at the top of ShutdownXLOG(), but could not find any clearly
> better place to do that than where it is.
>
> So I propose the attached patch. Any objections? Should this get
> back-patched? It's arguably a bug, though surely a minor one, that
> the message comes out when it does.

I would vote against a back-patch. And I kind of agree with Jim's
comments that we ought to consider sprinkling a few more debug
messages into the shutdown sequence.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Oleg Bartunov 2016-02-10 21:27:28 Re: old bug in full text parser
Previous Message Robbie Harwood 2016-02-10 21:06:59 Re: [PATCH v4] GSSAPI encryption support