Re: tracking commit timestamps

From: Petr Jelinek <petr(at)2ndquadrant(dot)com>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Steve Singer <steve(at)ssinger(dot)info>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Anssi Kääriäinen <anssi(dot)kaariainen(at)thl(dot)fi>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Jaime Casanova <jaime(at)2ndquadrant(dot)com>
Subject: Re: tracking commit timestamps
Date: 2014-11-25 16:18:35
Message-ID: 5474ABDB.3000209@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-www

On 25/11/14 17:16, Simon Riggs wrote:
> On 25 November 2014 at 13:35, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>
>> Can I check my understanding? Probably we cannot use this feature to calculate
>> the actual replication lag by, for example, comparing the result of
>> pg_last_committed_xact() in the master and that of
>> pg_last_xact_replay_timestamp()
>> in the standby. Because pg_last_xact_replay_timestamp() can return even
>> the timestamp of aborted transaction, but pg_last_committed_xact()
>> cannot. Right?
>
> It was intended for that, but I forgot that
> pg_last_xact_replay_timestamp() includes abort as well.
>
> I suggest we add a function that returns both the xid and timestamp on
> the standby:
> * pg_last_commit_replay_info() - which returns both the xid and
> timestamp of the last commit replayed on standby
> * then we use the xid from the standby to lookup the commit timestamp
> on the master.
> We then have two timestamps that refer to the same xid and can
> subtract to give us an exact replication lag.
>

Won't the pg_last_committed_xact() on slave + pg_xact_commit_timestamp()
on master with the xid returned by slave accomplish the same thing?

--
Petr Jelinek http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2014-11-25 16:31:05 Re: Replication connection URI?
Previous Message Simon Riggs 2014-11-25 16:16:00 Re: tracking commit timestamps

Browse pgsql-www by date

  From Date Subject
Next Message Simon Riggs 2014-11-25 16:51:23 Re: tracking commit timestamps
Previous Message Simon Riggs 2014-11-25 16:16:00 Re: tracking commit timestamps