Обсуждение: How to determine date / time of last postmaster restart

Поиск
Список
Период
Сортировка

How to determine date / time of last postmaster restart

От
adey
Дата:
Please let me know if there is a way to determine when the Postmaster was last restarted?
This is for tuning. I have stats_reset_on_server_start turned on, but I don't know when last the Postmaster was started, so I can't determine the period my current system stats cover.

Re: How to determine date / time of last postmaster restart

От
Tom Lane
Дата:
adey <adey11@gmail.com> writes:
> Please let me know if there is a way to determine when the Postmaster was
> last restarted?

The last postmaster start time, or the last database reset?  These are
not the same if any backends have crashed since the postmaster started.
For determining stats lifespan I think you need the latter.

Offhand I think the file timestamp of $PGDATA/postmaster.opts would do
for the postmaster start time, and postmaster.pid for the other (I think
postmaster.pid is updated during a reset).

PG 8.1 will have a function to return postmaster start time, but not
database reset time.  I wonder if this is misdefined --- if you are
trying to measure database uptime, the last reset would be more
appropriate to track.

            regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq


Re: [HACKERS] How to determine date / time of last postmaster restart

От
"Jim C. Nasby"
Дата:
On Tue, Sep 06, 2005 at 08:22:34PM -0400, Tom Lane wrote:
> PG 8.1 will have a function to return postmaster start time, but not
> database reset time.  I wonder if this is misdefined --- if you are
> trying to measure database uptime, the last reset would be more
> appropriate to track.

Is it too late to add a function that returns last reset time as well?
That would cover all bases and force some less confusing naming.
--
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461

Re: How to determine date / time of last postmaster restart

От
Peter Eisentraut
Дата:
adey wrote:
> Please let me know if there is a way to determine when the Postmaster
> was last restarted?

If you have configured your server log to contain timestamps, that is
your best bet to look.  In any case, the server log will tell when the
last shutdown was, so you can at least narrow down the time frame.  You
can also use pg_controldata to check the time of last change to
pg_control (which is changed when the server starts).

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Re: [HACKERS] How to determine date / time of last postmaster restart

От
Alvaro Herrera
Дата:
On Wed, Sep 07, 2005 at 12:38:44AM -0500, Jim C. Nasby wrote:
> On Tue, Sep 06, 2005 at 08:22:34PM -0400, Tom Lane wrote:
> > PG 8.1 will have a function to return postmaster start time, but not
> > database reset time.  I wonder if this is misdefined --- if you are
> > trying to measure database uptime, the last reset would be more
> > appropriate to track.
>
> Is it too late to add a function that returns last reset time as well?
> That would cover all bases and force some less confusing naming.

This would be one more vote in favour of initdb before next beta.
(pltemplate being the other one.)  We should set a threshold in order to
be able to decide ...

--
Alvaro Herrera -- Valdivia, Chile         Architect, www.EnterpriseDB.com
"Use it up, wear it out, make it do, or do without"

Re: [HACKERS] How to determine date / time of last postmaster restart

От
Tom Lane
Дата:
Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
> On Wed, Sep 07, 2005 at 12:38:44AM -0500, Jim C. Nasby wrote:
>> Is it too late to add a function that returns last reset time as well?
>> That would cover all bases and force some less confusing naming.

> This would be one more vote in favour of initdb before next beta.
> (pltemplate being the other one.)  We should set a threshold in order to
> be able to decide ...

It looks like we'll be initdb'ing to add pltemplate, so if someone wants
to submit a proposed patch for this ...

            regards, tom lane

Re: [HACKERS] How to determine date / time of last postmaster restart

От
"Jim C. Nasby"
Дата:
On Wed, Sep 07, 2005 at 09:22:55PM -0400, Tom Lane wrote:
> Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
> > On Wed, Sep 07, 2005 at 12:38:44AM -0500, Jim C. Nasby wrote:
> >> Is it too late to add a function that returns last reset time as well?
> >> That would cover all bases and force some less confusing naming.
>
> > This would be one more vote in favour of initdb before next beta.
> > (pltemplate being the other one.)  We should set a threshold in order to
> > be able to decide ...
>
> It looks like we'll be initdb'ing to add pltemplate, so if someone wants
> to submit a proposed patch for this ...

I might be able to do some of it; where would I need to capture reload
time?

Also, I'm thinking of leaving pg_postmaster_start_time as-is and adding
pg_postmaster_reload_time. Thoughts?

For reference, here's the original commit:
http://archives.postgresql.org/pgsql-committers/2005-06/msg00181.php
--
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461

Re: [HACKERS] How to determine date / time of last postmaster

От
Bruce Momjian
Дата:
Alvaro Herrera wrote:
> On Wed, Sep 07, 2005 at 12:38:44AM -0500, Jim C. Nasby wrote:
> > On Tue, Sep 06, 2005 at 08:22:34PM -0400, Tom Lane wrote:
> > > PG 8.1 will have a function to return postmaster start time, but not
> > > database reset time.  I wonder if this is misdefined --- if you are
> > > trying to measure database uptime, the last reset would be more
> > > appropriate to track.
> >
> > Is it too late to add a function that returns last reset time as well?
> > That would cover all bases and force some less confusing naming.
>
> This would be one more vote in favour of initdb before next beta.
> (pltemplate being the other one.)  We should set a threshold in order to
> be able to decide ...

Added to TODO:

    * Add function to report the time of the most recent server
      reload

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: How to determine date / time of last postmaster restart

От
Tom Lane
Дата:
adey <adey11@gmail.com> writes:
> Please let me know if there is a way to determine when the Postmaster was
> last restarted?

The last postmaster start time, or the last database reset?  These are
not the same if any backends have crashed since the postmaster started.
For determining stats lifespan I think you need the latter.

Offhand I think the file timestamp of $PGDATA/postmaster.opts would do
for the postmaster start time, and postmaster.pid for the other (I think
postmaster.pid is updated during a reset).

PG 8.1 will have a function to return postmaster start time, but not
database reset time.  I wonder if this is misdefined --- if you are
trying to measure database uptime, the last reset would be more
appropriate to track.

            regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq