Re: timestamp of the last replayed transaction

Lists: pgsql-hackers
From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: timestamp of the last replayed transaction
Date: 2010-11-02 11:38:28
Message-ID: AANLkTiknfd-BJc8ZyZ=BkB+H97_RShGhPrh0wJpo5JFj@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

After 9.0 release, I've often heard that some people want to know
how far transactions have been replayed in the standby in timestamp
rather than LSN. So I'm thinking to include the function which returns
the timestamp of the last applied transaction (i.e., commit/abort WAL
record) in the core.

Name: pg_last_replay_xact_timestamp (better name?)
Return Type: timestamp with time zone

Thought?

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center


From: Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: timestamp of the last replayed transaction
Date: 2010-11-02 13:38:27
Message-ID: m2vd4f4zho.fsf@2ndQuadrant.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Fujii Masao <masao(dot)fujii(at)gmail(dot)com> writes:
> After 9.0 release, I've often heard that some people want to know
> how far transactions have been replayed in the standby in timestamp
> rather than LSN. So I'm thinking to include the function which returns
> the timestamp of the last applied transaction (i.e., commit/abort WAL
> record) in the core.
>
> Name: pg_last_replay_xact_timestamp (better name?)
> Return Type: timestamp with time zone
>
> Thought?

How do you want to implement the tracking? Will it look like the
proposal in this thread:

http://archives.postgresql.org/pgsql-hackers/2010-05/msg01209.php

Regards,
--
Dimitri Fontaine
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Dimitri Fontaine <dimitri(at)2ndquadrant(dot)fr>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: timestamp of the last replayed transaction
Date: 2010-11-04 01:27:33
Message-ID: AANLkTimYnzF5vU=cZgmZU7a61UmmaREM4Z6u39BCF5OR@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Nov 2, 2010 at 10:38 PM, Dimitri Fontaine
<dimitri(at)2ndquadrant(dot)fr> wrote:
> Fujii Masao <masao(dot)fujii(at)gmail(dot)com> writes:
>> After 9.0 release, I've often heard that some people want to know
>> how far transactions have been replayed in the standby in timestamp
>> rather than LSN. So I'm thinking to include the function which returns
>> the timestamp of the last applied transaction (i.e., commit/abort WAL
>> record) in the core.
>>
>> Name: pg_last_replay_xact_timestamp (better name?)
>> Return Type: timestamp with time zone
>>
>> Thought?
>
> How do you want to implement the tracking?

I'm thinking to just expose GetLatestXTime(), i.e., XLogCtl->recoveryLastXTime.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Dimitri Fontaine <dimitri(at)2ndquadrant(dot)fr>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: timestamp of the last replayed transaction
Date: 2010-11-05 01:00:41
Message-ID: AANLkTikPivuROTFR466ji0Q44WgtTna02jbGT=0_zYE3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Nov 4, 2010 at 10:27 AM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> On Tue, Nov 2, 2010 at 10:38 PM, Dimitri Fontaine
> <dimitri(at)2ndquadrant(dot)fr> wrote:
>> Fujii Masao <masao(dot)fujii(at)gmail(dot)com> writes:
>>> After 9.0 release, I've often heard that some people want to know
>>> how far transactions have been replayed in the standby in timestamp
>>> rather than LSN. So I'm thinking to include the function which returns
>>> the timestamp of the last applied transaction (i.e., commit/abort WAL
>>> record) in the core.
>>>
>>> Name: pg_last_replay_xact_timestamp (better name?)
>>> Return Type: timestamp with time zone
>>>
>>> Thought?
>>
>> How do you want to implement the tracking?
>
> I'm thinking to just expose GetLatestXTime(), i.e., XLogCtl->recoveryLastXTime.

I attached the patch.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Attachment Content-Type Size
pg_last_replay_xact_timestamp_v1.patch application/octet-stream 3.3 KB

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Dimitri Fontaine <dimitri(at)2ndquadrant(dot)fr>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: timestamp of the last replayed transaction
Date: 2010-11-06 00:58:31
Message-ID: AANLkTin-Tp6hfhQyWuoUvVWfw1Pb-yOf6=KYz6Bhr4-s@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Nov 4, 2010 at 9:00 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> On Thu, Nov 4, 2010 at 10:27 AM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>> On Tue, Nov 2, 2010 at 10:38 PM, Dimitri Fontaine
>> <dimitri(at)2ndquadrant(dot)fr> wrote:
>>> Fujii Masao <masao(dot)fujii(at)gmail(dot)com> writes:
>>>> After 9.0 release, I've often heard that some people want to know
>>>> how far transactions have been replayed in the standby in timestamp
>>>> rather than LSN. So I'm thinking to include the function which returns
>>>> the timestamp of the last applied transaction (i.e., commit/abort WAL
>>>> record) in the core.
>>>>
>>>> Name: pg_last_replay_xact_timestamp (better name?)
>>>> Return Type: timestamp with time zone
>>>>
>>>> Thought?
>>>
>>> How do you want to implement the tracking?
>>
>> I'm thinking to just expose GetLatestXTime(), i.e., XLogCtl->recoveryLastXTime.
>
> I attached the patch.

This looks good, but how about adding:

if (!RecoveryInProgress())
PG_RETURN_NULL();

Otherwise, if we're in Hot Standby mode for a while and then enter
normal running, wouldn't this still return a (stale) value?

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


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Dimitri Fontaine <dimitri(at)2ndquadrant(dot)fr>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: timestamp of the last replayed transaction
Date: 2010-11-08 11:00:50
Message-ID: AANLkTimc1-29eiwWbFCZohmXYOOPG1r0Z4k8Y=baKwzR@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Nov 6, 2010 at 9:58 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> This looks good, but how about adding:
>
> if (!RecoveryInProgress())
>    PG_RETURN_NULL();
>
> Otherwise, if we're in Hot Standby mode for a while and then enter
> normal running, wouldn't this still return a (stale) value?

Yes, but isn't that (stale) value useful to check how far WAL records
have been replayed, *after failover*?

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Dimitri Fontaine <dimitri(at)2ndquadrant(dot)fr>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: timestamp of the last replayed transaction
Date: 2010-11-08 16:05:28
Message-ID: AANLkTi=4=j2-0eJEu2-OWjEzwWDvRmjLGphJpKcA0+cx@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Nov 8, 2010 at 6:00 AM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> On Sat, Nov 6, 2010 at 9:58 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> This looks good, but how about adding:
>>
>> if (!RecoveryInProgress())
>>    PG_RETURN_NULL();
>>
>> Otherwise, if we're in Hot Standby mode for a while and then enter
>> normal running, wouldn't this still return a (stale) value?
>
> Yes, but isn't that (stale) value useful to check how far WAL records
> have been replayed, *after failover*?

Oh, OK. I guess that makes sense. One other question - should we say
pg_last_xact_replay_timestamp() rather than
pg_xact_last_replay_timestamp(), for consistency with
pg_last_xlog_replay_location()?

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


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Dimitri Fontaine <dimitri(at)2ndquadrant(dot)fr>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: timestamp of the last replayed transaction
Date: 2010-11-09 13:44:33
Message-ID: AANLkTi=cBzGti2V1exgjJEZ+ukrokRNu_0KC8rgjs-sV@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Nov 9, 2010 at 1:05 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Mon, Nov 8, 2010 at 6:00 AM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>> On Sat, Nov 6, 2010 at 9:58 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>>> This looks good, but how about adding:
>>>
>>> if (!RecoveryInProgress())
>>>    PG_RETURN_NULL();
>>>
>>> Otherwise, if we're in Hot Standby mode for a while and then enter
>>> normal running, wouldn't this still return a (stale) value?
>>
>> Yes, but isn't that (stale) value useful to check how far WAL records
>> have been replayed, *after failover*?
>
> Oh, OK.  I guess that makes sense.  One other question - should we say
> pg_last_xact_replay_timestamp() rather than
> pg_xact_last_replay_timestamp(), for consistency with
> pg_last_xlog_replay_location()?

Yeah, pg_last_xact_replay_timestamp was my first idea. But, for me
(with poor English),
that sounded to return the timestamp of when the last transaction has
been replayed in
the standby, rather than the timestamp of the last replayed
transaction (i.e., when the
last replayed transaction has been committed in the master). So I
didn't choose that name.

But, pg_last_xact_replay_timestamp is more intuitive for many people?
If so, let's change
the name.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center


From: Josh Berkus <josh(at)agliodbs(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: timestamp of the last replayed transaction
Date: 2010-11-09 18:28:15
Message-ID: 4CD992BF.1080404@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 11/9/10 5:44 AM, Fujii Masao wrote:
> But, pg_last_xact_replay_timestamp is more intuitive for many people?
> If so, let's change
> the name.

*None* of these names are intuitive. So let's just go for consistency.

If you want an intuitive name, it would be:

pg_replication_log_timestamp()

--
-- Josh Berkus
PostgreSQL Experts Inc.
http://www.pgexperts.com


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: timestamp of the last replayed transaction
Date: 2010-11-10 01:55:46
Message-ID: AANLkTinu-aP-avqs7-WFDru0W3oJQhnuqwTJ3OgUTGgE@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Nov 10, 2010 at 3:28 AM, Josh Berkus <josh(at)agliodbs(dot)com> wrote:
> On 11/9/10 5:44 AM, Fujii Masao wrote:
>> But, pg_last_xact_replay_timestamp is more intuitive for many people?
>> If so, let's change
>> the name.
>
> *None* of these names are intuitive.  So let's just go for consistency.

OK. I changed the name to pg_last_xact_replay_timestamp.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Attachment Content-Type Size
pg_last_xact_replay_timestamp_v1.patch application/octet-stream 3.4 KB

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: timestamp of the last replayed transaction
Date: 2010-11-10 03:57:26
Message-ID: AANLkTim=pPe8F7HHjtevU5Wngk5nQKpBqDUqQNLcWqJ2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Nov 9, 2010 at 8:55 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> On Wed, Nov 10, 2010 at 3:28 AM, Josh Berkus <josh(at)agliodbs(dot)com> wrote:
>> On 11/9/10 5:44 AM, Fujii Masao wrote:
>>> But, pg_last_xact_replay_timestamp is more intuitive for many people?
>>> If so, let's change
>>> the name.
>>
>> *None* of these names are intuitive.  So let's just go for consistency.
>
> OK. I changed the name to pg_last_xact_replay_timestamp.

Committed.

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


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: timestamp of the last replayed transaction
Date: 2010-11-10 04:05:27
Message-ID: AANLkTimPonhgJThPBh_Bt-Ug6ckuKRO4eBXVhFsQKx4+@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Nov 10, 2010 at 12:57 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Tue, Nov 9, 2010 at 8:55 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>> On Wed, Nov 10, 2010 at 3:28 AM, Josh Berkus <josh(at)agliodbs(dot)com> wrote:
>>> On 11/9/10 5:44 AM, Fujii Masao wrote:
>>>> But, pg_last_xact_replay_timestamp is more intuitive for many people?
>>>> If so, let's change
>>>> the name.
>>>
>>> *None* of these names are intuitive.  So let's just go for consistency.
>>
>> OK. I changed the name to pg_last_xact_replay_timestamp.
>
> Committed.

Thanks!

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center