Re: Postgresql 9.1 pg_last_xact_replay_timestamp limitations

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Gabi Julien <gabi(dot)julien(at)broadsign(dot)com>
Cc: PostgreSQL pg-general List <pgsql-general(at)postgresql(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Postgresql 9.1 pg_last_xact_replay_timestamp limitations
Date: 2010-12-10 02:46:50
Message-ID: AANLkTi==vSoBU_Rr4Bs0xnXFxWZ_x5b=k0WO+STWx2Xh@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Fri, Dec 10, 2010 at 1:24 AM, Gabi Julien <gabi(dot)julien(at)broadsign(dot)com> wrote:
> On Wednesday 08 December 2010 21:58:46 you wrote:
>> On Thu, Dec 9, 2010 at 1:37 AM, Gabi Julien <gabi(dot)julien(at)broadsign(dot)com> wrote:
>> > slave# /etc/init.d/postgresql start
>> > slave# psql -hlocalhost my_db -c "select pg_last_xact_replay_timestamp(), now() as not_modified_since;"
>> >  pg_last_xact_replay_timestamp |      not_modified_since
>> > -------------------------------+-------------------------------
>> >                               | 2010-12-08 16:06:09.920219+00
>
>> We should return the timestamp of last valid checkpoint rather than NULL in that
>> case?
>
> Well, I think this behavior would be more appreciated by postgresql users in general. The case where the slave can be restarted after a clean shutdown is rare but we need to consider it nonetheless. In my case I implemented a custom function that reads the last returned timestamp from a new file on disk. This is not a perfect solution since the value returned might be older then the actual state of the replication but it's good enough for my needs.

The second question is; What should be returned when the server has been
started normally without recovery? NULL? The timestamp of last valid checkpoint?

The third question is; What should be returned while replaying WAL records which
exist between REDO starting point and checkpoint? In this case, it seems bad to
return the timestamp of the checkpoint whenever there is no replay transaction,
since the result timestamp would go back once at least one transaction has been
replayed before reaching the checkpoint record.

Regards,

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message gvim 2010-12-10 03:36:01 Import ID column data then convert to SEQUENCE?
Previous Message Robert Fitzpatrick 2010-12-10 01:44:47 Invalid byte sequence

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2010-12-10 02:47:46 Re: Final(?) proposal for wal_sync_method changes
Previous Message Greg Smith 2010-12-10 02:26:36 Re: Instrument checkpoint sync calls