pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: pavan95 <pavan.postgresdba@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: How to get postmaster shut down time in postgres?
Date: Mon, 04 Jun 2018 13:31:12 -0400
Message-ID: <31954.1528133472@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwbuD8kh01V07MX2ZJeJ7_Hr1PZ9EJWGEq9SSvHpd1QEtQ@mail.gmail.com>
References: <1528118250600-0.post@n3.nabble.com>
	<CANu8FiyrGKbNxd39rh8xJ1B_o+61jO6B5K1xSbVWK6f9WdoiJg@mail.gmail.com>
	<1528119860207-0.post@n3.nabble.com>
	<CAKFQuwbuD8kh01V07MX2ZJeJ7_Hr1PZ9EJWGEq9SSvHpd1QEtQ@mail.gmail.com>

"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Mon, Jun 4, 2018 at 6:44 AM, pavan95 <pavan.postgresdba@gmail.com> wrote:
>> The main reason for my requirement is to find the time swing between server
>> stop and start.

> Not all server stops are logged/evented (i.e., crashes), though by
> definition all successful starts are (or at least can be).​

Yeah, the server-crash case is the one that makes this requirement
hard to solve internally to the server.  In a normal ("smart")
shutdown, there might be a case for letting something happen just
before we begin the final shutdown sequence, but there's no such
hook at present.  Anyway, that still leaves a definitional question
--- are you looking for the time that shutdown begins, or when it's
done?  By definition, the latter is too late to make a table entry.

One thing you might consider is running pg_controldata just before you
start the server, and noting its report of "pg_control last modified".
That would either be the shutdown-done point in a non-crash case, or
(probably) the last checkpoint time in a crash case.  As others mentioned,
checking for the time of the last message in the postmaster log would
likely provide a more accurate result, but it's also a lot more
complicated.

			regards, tom lane




view thread (14+ messages)  latest in thread

Message-ID: <31954.1528133472@sss.pgh.pa.us>
Permalink:  ../31954.1528133472@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/31954.1528133472@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, pavan.postgresdba@gmail.com
  Subject: Re: How to get postmaster shut down time in postgres?
  In-Reply-To: <31954.1528133472@sss.pgh.pa.us>
  References: <1528118250600-0.post@n3.nabble.com> <CANu8FiyrGKbNxd39rh8xJ1B_o+61jO6B5K1xSbVWK6f9WdoiJg@mail.gmail.com> <1528119860207-0.post@n3.nabble.com> <CAKFQuwbuD8kh01V07MX2ZJeJ7_Hr1PZ9EJWGEq9SSvHpd1QEtQ@mail.gmail.com> <31954.1528133472@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox