Re: pg_stop_backup wait bug fix

Lists: pgsql-hackers
From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: pg_stop_backup wait bug fix
Date: 2008-10-08 13:23:06
Message-ID: 1223472186.4747.301.camel@ebony.2ndQuadrant
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Minor bug fix for pg_stop_backup() to prevent it waiting longer than
necessary in certain circumstances.

Was originally part of recovery_infrastructure patch.

--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support

Attachment Content-Type Size
pg_stop_backup_wait.v1.patch text/x-patch 1.9 KB

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_stop_backup wait bug fix
Date: 2008-11-07 21:32:00
Message-ID: 20081107213200.GI5507@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Simon Riggs wrote:
> Minor bug fix for pg_stop_backup() to prevent it waiting longer than
> necessary in certain circumstances.

As far as I can tell, this patch needs to be applied to HEAD, 8.3 and
8.2 (when xlog switch was implemented), and in fact it applies cleanly
to them. Please confirm.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_stop_backup wait bug fix
Date: 2008-11-08 10:22:09
Message-ID: 1226139729.27904.211.camel@ebony.2ndQuadrant
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On Fri, 2008-11-07 at 18:32 -0300, Alvaro Herrera wrote:
> Simon Riggs wrote:
> > Minor bug fix for pg_stop_backup() to prevent it waiting longer than
> > necessary in certain circumstances.
>
> As far as I can tell, this patch needs to be applied to HEAD, 8.3 and
> 8.2 (when xlog switch was implemented), and in fact it applies cleanly
> to them. Please confirm.

There are other patches that we should consider along with this one.

This particular patch only has meaning when applied with the changes to
pg_stop_backup() earlier in 8.4dev cycle. It isn't a bug in xlog switch,
it is a bug in how the new waiting code interprets the return value from
xlog switch.

--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support


From: "Fujii Masao" <masao(dot)fujii(at)gmail(dot)com>
To: "Simon Riggs" <simon(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_stop_backup wait bug fix
Date: 2008-11-19 03:30:54
Message-ID: 3f0b79eb0811181930n7238c77ah1ee5c9a88d1d4988@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

On Wed, Oct 8, 2008 at 10:23 PM, Simon Riggs <simon(at)2ndquadrant(dot)com> wrote:
> Minor bug fix for pg_stop_backup() to prevent it waiting longer than
> necessary in certain circumstances.

Why don't you use XLByteToPrevSeg like pg_xlogfile_name?
I think that we should uniform the logic as much as possible.

Regards,

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


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_stop_backup wait bug fix
Date: 2008-12-02 20:13:02
Message-ID: 493596CE.6040408@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Fujii Masao wrote:
> On Wed, Oct 8, 2008 at 10:23 PM, Simon Riggs <simon(at)2ndquadrant(dot)com> wrote:
>> Minor bug fix for pg_stop_backup() to prevent it waiting longer than
>> necessary in certain circumstances.
>
> Why don't you use XLByteToPrevSeg like pg_xlogfile_name?
> I think that we should uniform the logic as much as possible.

Agreed, should use XLByteToPrevSeg. But I wonder if we can just replace
the current XLByteToSeg call with XLByteToPrevSeg? That would offset the
return value of the function by one byte as well, as well as the value
printed to the backup history file. In fact, I think the original patch
got that wrong; it would return the location of the *beginning* of the
last xlog file.

I also noticed that the 2nd BackupHistoryFileName call in that function
is useless; histfilepath variable is already filled in earlier.

How does the attached patch look to you? Do you have an easy way to test
this?

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

Attachment Content-Type Size
pg_stop_backup_wait-heikki-1.patch text/x-diff 1.8 KB

From: "Fujii Masao" <masao(dot)fujii(at)gmail(dot)com>
To: "Heikki Linnakangas" <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: "Simon Riggs" <simon(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_stop_backup wait bug fix
Date: 2008-12-03 04:26:12
Message-ID: 3f0b79eb0812022026r379d6331k376c4fa87c7bdc85@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Dec 3, 2008 at 5:13 AM, Heikki Linnakangas
<heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
> Fujii Masao wrote:
>>
>> On Wed, Oct 8, 2008 at 10:23 PM, Simon Riggs <simon(at)2ndquadrant(dot)com>
>> wrote:
>>>
>>> Minor bug fix for pg_stop_backup() to prevent it waiting longer than
>>> necessary in certain circumstances.
>>
>> Why don't you use XLByteToPrevSeg like pg_xlogfile_name?
>> I think that we should uniform the logic as much as possible.
>
> Agreed, should use XLByteToPrevSeg. But I wonder if we can just replace the
> current XLByteToSeg call with XLByteToPrevSeg? That would offset the return
> value of the function by one byte as well, as well as the value printed to
> the backup history file. In fact, I think the original patch got that wrong;
> it would return the location of the *beginning* of the last xlog file.

You're right. As you say, the value (stopxlogfilename) printed to the backup
history file is wrong. But, since the value is not used fortunately,
any troubles
have not come up. So, I think that we can just replace them.

>
> I also noticed that the 2nd BackupHistoryFileName call in that function is
> useless; histfilepath variable is already filled in earlier.

Somewhat confusingly, BackupHistoryFileName is called only once. Isn't 1st
(which probably you thought) BackupHistoryFilePath? In order to prevent
confusion, we should add new local variable (histfilename) for the backup
history file name?

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: Simon Riggs <simon(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_stop_backup wait bug fix
Date: 2008-12-03 08:24:40
Message-ID: 49364248.2090001@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Fujii Masao wrote:
> On Wed, Dec 3, 2008 at 5:13 AM, Heikki Linnakangas
> <heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
>> Agreed, should use XLByteToPrevSeg. But I wonder if we can just replace the
>> current XLByteToSeg call with XLByteToPrevSeg? That would offset the return
>> value of the function by one byte as well, as well as the value printed to
>> the backup history file. In fact, I think the original patch got that wrong;
>> it would return the location of the *beginning* of the last xlog file.
>
> You're right. As you say, the value (stopxlogfilename) printed to the backup
> history file is wrong. But, since the value is not used fortunately,
> any troubles
> have not come up. So, I think that we can just replace them.

Changing the return value doesn't seem like a good idea. If nothing
else, it would be complicated to explain what it returns. I committed a
patch that changes the waiting behavior, but not the return value or
what's written into the backup label file,

>> I also noticed that the 2nd BackupHistoryFileName call in that function is
>> useless; histfilepath variable is already filled in earlier.
>
> Somewhat confusingly, BackupHistoryFileName is called only once. Isn't 1st
> (which probably you thought) BackupHistoryFilePath?

Ouch, you're right. That's subtle.

> In order to prevent
> confusion, we should add new local variable (histfilename) for the backup
> history file name?

Agreed. I included that in the patch.

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


From: "Ibrar Ahmed" <ibrar(dot)ahmad(at)gmail(dot)com>
To: "Heikki Linnakangas" <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: "Fujii Masao" <masao(dot)fujii(at)gmail(dot)com>, "Simon Riggs" <simon(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_stop_backup wait bug fix
Date: 2008-12-03 09:29:06
Message-ID: 8494ccf60812030129i35e26745q789c8f5bb8a6ca8e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

I have looked at the patch and it looks OK to me. BTW I am not too
much familiar with this area of code, so I am not at the position to
argue that patch -:) . I haven't found an easy way to test the patch.

On Wed, Dec 3, 2008 at 1:24 PM, Heikki Linnakangas
<heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
> Fujii Masao wrote:
>>
>> On Wed, Dec 3, 2008 at 5:13 AM, Heikki Linnakangas
>> <heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
>>>
>>> Agreed, should use XLByteToPrevSeg. But I wonder if we can just replace
>>> the
>>> current XLByteToSeg call with XLByteToPrevSeg? That would offset the
>>> return
>>> value of the function by one byte as well, as well as the value printed
>>> to
>>> the backup history file. In fact, I think the original patch got that
>>> wrong;
>>> it would return the location of the *beginning* of the last xlog file.
>>
>> You're right. As you say, the value (stopxlogfilename) printed to the
>> backup
>> history file is wrong. But, since the value is not used fortunately,
>> any troubles
>> have not come up. So, I think that we can just replace them.
>
> Changing the return value doesn't seem like a good idea. If nothing else, it
> would be complicated to explain what it returns. I committed a patch that
> changes the waiting behavior, but not the return value or what's written
> into the backup label file,
>
>>> I also noticed that the 2nd BackupHistoryFileName call in that function
>>> is
>>> useless; histfilepath variable is already filled in earlier.
>>
>> Somewhat confusingly, BackupHistoryFileName is called only once. Isn't 1st
>> (which probably you thought) BackupHistoryFilePath?
>
> Ouch, you're right. That's subtle.
>
>> In order to prevent
>> confusion, we should add new local variable (histfilename) for the backup
>> history file name?
>
> Agreed. I included that in the patch.
>
> --
> Heikki Linnakangas
> EnterpriseDB http://www.enterprisedb.com
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

--
Ibrar Ahmed
EnterpriseDB http://www.enterprisedb.com