pending patch: Re: Streaming replication and pg_xlogfile_name()

Lists: pgsql-hackers
From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: Erik Rijkers <er(at)xs4all(dot)nl>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: pending patch: Re: Streaming replication and pg_xlogfile_name()
Date: 2010-03-30 09:14:48
Message-ID: 3f0b79eb1003300214r6cf98c46tc9be5d563ccf48db@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Mar 3, 2010 at 11:03 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> On Tue, Mar 2, 2010 at 10:52 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>>> It's not clear what it should return, a TLI corresponding the filename
>>> of the WAL segment the record was replayed from, so that you can use
>>> pg_xlogfile_name() to find out the filename of the WAL segment being
>>> replayed, or the accurate TLI of the record being replayed. I'm leaning
>>> towards the latter, it feels more correct and accurate, but you could
>>> argue for the former too. In any case, it needs to be well-defined.
>>
>> I agree with you that the latter is more correct and accurate. The simple
>> fix is updating the lastPageTLI with the CheckPoint->ThisTimeLineID when
>> replaying the shutdown checkpoint record. Though we might need to use new
>> variable to keep the last applied timeline instead of the lastPageTLI.
>
> Here is the revised patch. I used new local variable instead of lastPageTLI
> to track the tli of last applied record. It is updated with the tli of the
> log page header when reading the page, and with the tli of the checkpoint
> record when replaying the checkpoint shutdown record that changes the tli.
> So pg_last_xlog_replay_location() can return the accurate tli of the last
> applied record.

I rebased the patch to HEAD. Should I think that the patch has been rejected
because it has remained pending for about one month?

Regards,

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

Attachment Content-Type Size
extend_format_of_recovery_info_funcs_v5.patch application/octet-stream 13.9 KB

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, Erik Rijkers <er(at)xs4all(dot)nl>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pending patch: Re: Streaming replication and pg_xlogfile_name()
Date: 2010-04-01 17:22:40
Message-ID: q2h603c8f071004011022z8ffd0999r3fcffbfa77dd56bf@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Mar 30, 2010 at 5:14 AM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> On Wed, Mar 3, 2010 at 11:03 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>> On Tue, Mar 2, 2010 at 10:52 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>>>> It's not clear what it should return, a TLI corresponding the filename
>>>> of the WAL segment the record was replayed from, so that you can use
>>>> pg_xlogfile_name() to find out the filename of the WAL segment being
>>>> replayed, or the accurate TLI of the record being replayed. I'm leaning
>>>> towards the latter, it feels more correct and accurate, but you could
>>>> argue for the former too. In any case, it needs to be well-defined.
>>>
>>> I agree with you that the latter is more correct and accurate. The simple
>>> fix is updating the lastPageTLI with the CheckPoint->ThisTimeLineID when
>>> replaying the shutdown checkpoint record. Though we might need to use new
>>> variable to keep the last applied timeline instead of the lastPageTLI.
>>
>> Here is the revised patch. I used new local variable instead of lastPageTLI
>> to track the tli of last applied record. It is updated with the tli of the
>> log page header when reading the page, and with the tli of the checkpoint
>> record when replaying the checkpoint shutdown record that changes the tli.
>> So pg_last_xlog_replay_location() can return the accurate tli of the last
>> applied record.
>
> I rebased the patch to HEAD. Should I think that the patch has been rejected
> because it has remained pending for about one month?

Can someone explain to me in plain language what problem this is
trying to fix? I'm having trouble figuring it out.

...Robert


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, Erik Rijkers <er(at)xs4all(dot)nl>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pending patch: Re: Streaming replication and pg_xlogfile_name()
Date: 2010-04-02 02:53:37
Message-ID: k2i3f0b79eb1004011953i463dadfdy39a6d22c7c1bdee8@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Apr 2, 2010 at 2:22 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> Can someone explain to me in plain language what problem this is
> trying to fix?  I'm having trouble figuring it out.

The problem is that pg_xlogfile_name(pg_last_xlog_receive_location()) and
pg_xlogfile_name(pg_last_xlog_replay_location()) might report an inaccurate
WAL file name because currently pg_xlogfile_name() always uses the current
timeline to calculate the WAL file name. For example, even though the last
applied WAL file is 000000010000000000000002, the standby wrongly reports
that 000000000000000000000002 has been applied last.

postgres=# SELECT l lsn, pg_xlogfile_name(l) filename FROM
pg_last_xlog_replay_location() AS l;
lsn | filename
-----------+--------------------------
0/200FF70 | 000000000000000000000002
(1 row)

$ ls sby/pg_xlog/
000000010000000000000002 000000010000000000000003 archive_status

Regards,

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


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Erik Rijkers <er(at)xs4all(dot)nl>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pending patch: Re: Streaming replication and pg_xlogfile_name()
Date: 2010-04-06 10:25:13
Message-ID: 4BBB0C09.1050708@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Fujii Masao wrote:
> On Fri, Apr 2, 2010 at 2:22 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> Can someone explain to me in plain language what problem this is
>> trying to fix? I'm having trouble figuring it out.
>
> The problem is that pg_xlogfile_name(pg_last_xlog_receive_location()) and
> pg_xlogfile_name(pg_last_xlog_replay_location()) might report an inaccurate
> WAL file name because currently pg_xlogfile_name() always uses the current
> timeline to calculate the WAL file name. For example, even though the last
> applied WAL file is 000000010000000000000002, the standby wrongly reports
> that 000000000000000000000002 has been applied last.

Should we throw an error in pg_xlogfile_name() if called during
recovery? It's not doing anything useful as it is.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Erik Rijkers <er(at)xs4all(dot)nl>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pending patch: Re: Streaming replication and pg_xlogfile_name()
Date: 2010-04-06 11:02:54
Message-ID: z2n3f0b79eb1004060402q3bb56e98ob092b455875b5569@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Apr 6, 2010 at 7:25 PM, Heikki Linnakangas
<heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
> Fujii Masao wrote:
>> On Fri, Apr 2, 2010 at 2:22 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>>> Can someone explain to me in plain language what problem this is
>>> trying to fix?  I'm having trouble figuring it out.
>>
>> The problem is that pg_xlogfile_name(pg_last_xlog_receive_location()) and
>> pg_xlogfile_name(pg_last_xlog_replay_location()) might report an inaccurate
>> WAL file name because currently pg_xlogfile_name() always uses the current
>> timeline to calculate the WAL file name. For example, even though the last
>> applied WAL file is 000000010000000000000002, the standby wrongly reports
>> that 000000000000000000000002 has been applied last.
>
> Should we throw an error in pg_xlogfile_name() if called during
> recovery? It's not doing anything useful as it is.

I have no objection for now.

Regards,

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


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Erik Rijkers <er(at)xs4all(dot)nl>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pending patch: Re: Streaming replication and pg_xlogfile_name()
Date: 2010-04-06 12:05:40
Message-ID: q2j3f0b79eb1004060505i5372d16sbf6b3f8827f14a08@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Apr 6, 2010 at 8:02 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>> Should we throw an error in pg_xlogfile_name() if called during
>> recovery? It's not doing anything useful as it is.
>
> I have no objection for now.

Here is the patch.

Regards,

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

Attachment Content-Type Size
forbid_pg_xlogfile_name_during_recovery_v1.patch application/octet-stream 1.8 KB

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Erik Rijkers <er(at)xs4all(dot)nl>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pending patch: Re: Streaming replication and pg_xlogfile_name()
Date: 2010-04-06 14:48:55
Message-ID: 4BBB49D7.8020804@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Fujii Masao wrote:
> On Tue, Apr 6, 2010 at 8:02 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>>> Should we throw an error in pg_xlogfile_name() if called during
>>> recovery? It's not doing anything useful as it is.
>> I have no objection for now.
>
> Here is the patch.
> ...
> + if (RecoveryInProgress())
> + ereport(ERROR,
> + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
> + errmsg("recovery is in progress"),
> + errhint("WAL control functions cannot be executed during recovery.")));
> +

The hint is a bit confusing for pg_xlogfile_name(). pg_xlogfile_name()
is hardly a WAL control function like pg_start/stop_backup() are. How
about "pg_xlogfile_name() cannot be executed during recovery."?

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Erik Rijkers <er(at)xs4all(dot)nl>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pending patch: Re: Streaming replication and pg_xlogfile_name()
Date: 2010-04-07 01:58:18
Message-ID: z2x3f0b79eb1004061858n84ccb711pb56ff0e0be4911b5@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Apr 6, 2010 at 11:48 PM, Heikki Linnakangas
<heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
> Fujii Masao wrote:
>> On Tue, Apr 6, 2010 at 8:02 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>>>> Should we throw an error in pg_xlogfile_name() if called during
>>>> recovery? It's not doing anything useful as it is.
>>> I have no objection for now.
>>
>> Here is the patch.
>> ...
>> +     if (RecoveryInProgress())
>> +             ereport(ERROR,
>> +                             (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
>> +                              errmsg("recovery is in progress"),
>> +                              errhint("WAL control functions cannot be executed during recovery.")));
>> +
>
> The hint is a bit confusing for pg_xlogfile_name(). pg_xlogfile_name()
> is hardly a WAL control function like pg_start/stop_backup() are. How
> about "pg_xlogfile_name() cannot be executed during recovery."?

OK. Here is the revised patch.

Regards,

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

Attachment Content-Type Size
forbid_pg_xlogfile_name_during_recovery_v2.patch application/octet-stream 1.8 KB

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Erik Rijkers <er(at)xs4all(dot)nl>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pending patch: Re: Streaming replication and pg_xlogfile_name()
Date: 2010-04-07 06:13:14
Message-ID: 4BBC227A.2040702@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Fujii Masao wrote:
> On Tue, Apr 6, 2010 at 11:48 PM, Heikki Linnakangas
> <heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
>> Fujii Masao wrote:
>>> On Tue, Apr 6, 2010 at 8:02 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>>>>> Should we throw an error in pg_xlogfile_name() if called during
>>>>> recovery? It's not doing anything useful as it is.
>>>> I have no objection for now.
>>> Here is the patch.
>>> ...
>>> + if (RecoveryInProgress())
>>> + ereport(ERROR,
>>> + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
>>> + errmsg("recovery is in progress"),
>>> + errhint("WAL control functions cannot be executed during recovery.")));
>>> +
>> The hint is a bit confusing for pg_xlogfile_name(). pg_xlogfile_name()
>> is hardly a WAL control function like pg_start/stop_backup() are. How
>> about "pg_xlogfile_name() cannot be executed during recovery."?
>
> OK. Here is the revised patch.

Thanks, committed.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com