Re: [PATCHES] WIP archive_timeout patch

Lists: pgsql-hackerspgsql-patches
From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Subject: WIP archive_timeout patch
Date: 2006-07-31 22:47:38
Message-ID: 1154386058.3226.34.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches


WIP archive_timeout.

All we need to do is add LWLock support to archiver.
Thoughts/ideas/hints welcome.

This is a patch-on-patch atop the xswitch.patch recently posted.

--
Simon Riggs
EnterpriseDB http://www.enterprisedb.com

Attachment Content-Type Size
archivetimeout.patch text/x-patch 8.1 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgresql(dot)org, Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: WIP archive_timeout patch
Date: 2006-08-03 17:38:16
Message-ID: 21028.1154626696@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Simon Riggs <simon(at)2ndquadrant(dot)com> writes:
> WIP archive_timeout.
> All we need to do is add LWLock support to archiver.
> Thoughts/ideas/hints welcome.

Hint: this isn't the archiver's problem, and so you don't need to get
the archiver involved in the solution. I'd suggest bgwriter as a
reasonably appropriate place instead.

regards, tom lane


From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: WIP archive_timeout patch
Date: 2006-08-03 18:03:42
Message-ID: 1154628222.2592.1017.camel@holly
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Thu, 2006-08-03 at 13:38 -0400, Tom Lane wrote:
> Simon Riggs <simon(at)2ndquadrant(dot)com> writes:
> > WIP archive_timeout.
> > All we need to do is add LWLock support to archiver.
> > Thoughts/ideas/hints welcome.
>
> Hint: this isn't the archiver's problem, and so you don't need to get
> the archiver involved in the solution. I'd suggest bgwriter as a
> reasonably appropriate place instead.

OK

--
Simon Riggs
EnterpriseDB http://www.enterprisedb.com


From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: WIP archive_timeout patch
Date: 2006-08-04 20:38:04
Message-ID: 1154723884.2495.18.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Thu, 2006-08-03 at 19:03 +0100, Simon Riggs wrote:
> On Thu, 2006-08-03 at 13:38 -0400, Tom Lane wrote:
> > Simon Riggs <simon(at)2ndquadrant(dot)com> writes:
> > > WIP archive_timeout.
> > > All we need to do is add LWLock support to archiver.
> > > Thoughts/ideas/hints welcome.
> >
> > Hint: this isn't the archiver's problem, and so you don't need to get
> > the archiver involved in the solution. I'd suggest bgwriter as a
> > reasonably appropriate place instead.
>
> OK

A slightly fuller answer:

Yes, thats a safer place than archiver, so I'll add it to bgwriter as
you suggest. Should have a patch complete by Tuesday, since travelling
now.

--
Simon Riggs
EnterpriseDB http://www.enterprisedb.com


From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Hannu Krosing <hannu(at)skype(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: WIP archive_timeout patch
Date: 2006-08-16 22:10:18
Message-ID: 1155766218.2649.444.camel@holly
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Wed, 2006-08-16 at 10:09 +0100, Simon Riggs wrote:
> On Thu, 2006-08-03 at 19:03 +0100, Simon Riggs wrote:
> > On Thu, 2006-08-03 at 13:38 -0400, Tom Lane wrote:
> > > Simon Riggs <simon(at)2ndquadrant(dot)com> writes:
> > > > WIP archive_timeout.
> > > > All we need to do is add LWLock support to archiver.
> > > > Thoughts/ideas/hints welcome.
> > >
> > > Hint: this isn't the archiver's problem, and so you don't need to get
> > > the archiver involved in the solution. I'd suggest bgwriter as a
> > > reasonably appropriate place instead.
>
> Revised patch enclosed, now believed to be production ready. This
> implements regular log switching using the archive_timeout GUC.

Further patch enclosed implementing these changes plus the record type
version of pg_xlogfile_name_offset()

--
Simon Riggs
EnterpriseDB http://www.enterprisedb.com

Attachment Content-Type Size
archive_timeout++.patch text/x-patch 24.5 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Hannu Krosing <hannu(at)skype(dot)net>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [PATCHES] WIP archive_timeout patch
Date: 2006-08-17 23:11:25
Message-ID: 516.1155856285@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Simon Riggs <simon(at)2ndquadrant(dot)com> writes:
>> Revised patch enclosed, now believed to be production ready. This
>> implements regular log switching using the archive_timeout GUC.

> Further patch enclosed implementing these changes plus the record type
> version of pg_xlogfile_name_offset()

Applied with minor changes --- it seemed better to me to put tracking of
the last xlog switch time directly into xlog.c, instead of having the
bgwriter code try to determine whether a switch had happened recently.

I noticed a minor annoyance while testing: when the system is completely
idle, you get a forced segment switch every checkpoint_timeout seconds,
even though there is nothing useful to log. The checkpoint code is
smart enough not to do a checkpoint if nothing has happened since the
last one, and the xlog switch code is smart enough not to do a switch
if nothing has happened since the last one ... but they aren't talking
to each other and so each one's change looks like "something happened"
to the other one. I'm not sure how much trouble it's worth taking to
prevent this scenario, though. If you can't afford a WAL file switch
every five minutes, you probably shouldn't be using archive_timeout
anyway ...

regards, tom lane


From: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Hannu Krosing <hannu(at)skype(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] WIP archive_timeout patch
Date: 2006-08-18 00:02:30
Message-ID: 44E50396.3010101@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> Simon Riggs <simon(at)2ndquadrant(dot)com> writes:
>>> Revised patch enclosed, now believed to be production ready. This
>>> implements regular log switching using the archive_timeout GUC.
>
>> Further patch enclosed implementing these changes plus the record type
>> version of pg_xlogfile_name_offset()
>
> Applied with minor changes --- it seemed better to me to put tracking of
> the last xlog switch time directly into xlog.c, instead of having the
> bgwriter code try to determine whether a switch had happened recently.
>
> I noticed a minor annoyance while testing: when the system is completely
> idle, you get a forced segment switch every checkpoint_timeout seconds,
> even though there is nothing useful to log. The checkpoint code is
> smart enough not to do a checkpoint if nothing has happened since the
> last one, and the xlog switch code is smart enough not to do a switch
> if nothing has happened since the last one ... but they aren't talking
> to each other and so each one's change looks like "something happened"
> to the other one. I'm not sure how much trouble it's worth taking to
> prevent this scenario, though. If you can't afford a WAL file switch
> every five minutes, you probably shouldn't be using archive_timeout
> anyway ...

Actually, this behaviour IMHO even has it's advantages - if you can be
sure that at least one wal will be archived every 5 minutes, then it's
easy to monitor the replication - you can just watch the logfile if the
slave, and send a failure notice if no logfile is imported at least
every 10 minutes or so.

Of course, for this to be useful, the documentation would have to tell
people about that behaviour, and it couldn't easily be changed in the next
release...

greetings, Florian Pflug


From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Hannu Krosing <hannu(at)skype(dot)net>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [PATCHES] WIP archive_timeout patch
Date: 2006-08-18 08:14:47
Message-ID: 1155888887.2591.16.camel@holly
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Thu, 2006-08-17 at 19:11 -0400, Tom Lane wrote:
> Simon Riggs <simon(at)2ndquadrant(dot)com> writes:
> >> Revised patch enclosed, now believed to be production ready. This
> >> implements regular log switching using the archive_timeout GUC.
>
> > Further patch enclosed implementing these changes plus the record type
> > version of pg_xlogfile_name_offset()
>
> Applied with minor changes --- it seemed better to me to put tracking of
> the last xlog switch time directly into xlog.c, instead of having the
> bgwriter code try to determine whether a switch had happened recently.

Code location: sure.

> I noticed a minor annoyance while testing: when the system is completely
> idle, you get a forced segment switch every checkpoint_timeout seconds,
> even though there is nothing useful to log. The checkpoint code is
> smart enough not to do a checkpoint if nothing has happened since the
> last one, and the xlog switch code is smart enough not to do a switch
> if nothing has happened since the last one ... but they aren't talking
> to each other and so each one's change looks like "something happened"
> to the other one. I'm not sure how much trouble it's worth taking to
> prevent this scenario, though. If you can't afford a WAL file switch
> every five minutes, you probably shouldn't be using archive_timeout
> anyway ...

I noticed that minor annoyance and understood that I had fixed it before
submitting. That was the reason for putting the code in bgwriter to
check whether the pointer had moved before attempting the switch...
perhaps that functionality has been removed?

--
Simon Riggs
EnterpriseDB http://www.enterprisedb.com


From: "Zeugswetter Andreas DCP SD" <ZeugswetterA(at)spardat(dot)at>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Simon Riggs" <simon(at)2ndquadrant(dot)com>
Cc: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>, "Bruce Momjian" <bruce(at)momjian(dot)us>, "Hannu Krosing" <hannu(at)skype(dot)net>, <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: [PATCHES] WIP archive_timeout patch
Date: 2006-08-18 08:20:47
Message-ID: E1539E0ED7043848906A8FF995BDA5790140FDD9@m0143.s-mxs.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches


> I noticed a minor annoyance while testing: when the system is
> completely idle, you get a forced segment switch every
> checkpoint_timeout seconds, even though there is nothing
> useful to log. The checkpoint code is smart enough not to do
> a checkpoint if nothing has happened since the last one, and
> the xlog switch code is smart enough not to do a switch if
> nothing has happened since the last one ... but they aren't
> talking to each other and so each one's change looks like
> "something happened"
> to the other one. I'm not sure how much trouble it's worth
> taking to prevent this scenario, though. If you can't afford
> a WAL file switch every five minutes, you probably shouldn't
> be using archive_timeout anyway ...

Um, I would have thought practical timeouts would be rather more
than 5 minutes than less. So this does seem like a problem to me :-(

Andreas


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Hannu Krosing <hannu(at)skype(dot)net>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [PATCHES] WIP archive_timeout patch
Date: 2006-08-18 12:52:03
Message-ID: 7250.1155905523@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Simon Riggs <simon(at)2ndquadrant(dot)com> writes:
> On Thu, 2006-08-17 at 19:11 -0400, Tom Lane wrote:
>> I noticed a minor annoyance while testing: when the system is completely
>> idle, you get a forced segment switch every checkpoint_timeout seconds,
>> even though there is nothing useful to log. The checkpoint code is
>> smart enough not to do a checkpoint if nothing has happened since the
>> last one, and the xlog switch code is smart enough not to do a switch
>> if nothing has happened since the last one ... but they aren't talking
>> to each other and so each one's change looks like "something happened"
>> to the other one.

> I noticed that minor annoyance and understood that I had fixed it before
> submitting. That was the reason for putting the code in bgwriter to
> check whether the pointer had moved before attempting the switch...
> perhaps that functionality has been removed?

No, the original form of the patch was equally vulnerable. AFAICS the
only way to prevent this would be for XLogRequestSwitch (or really
XLogInsert, which does the heavy lifting for this) to suppress a switch
if the current segment is empty *or* contains only a checkpoint WAL
record. Basically it'd have to pretend the checkpoint record is not
there. This is doable but seems a bit weird --- in particular, that
would mean that pg_switch_xlog sometimes returns a pointer less than
pg_current_xlog_location, which might confuse backup scripts.

On the whole I'm leaning towards not changing it. As Florian mentioned,
guaranteed segment-every-checkpoint isn't completely without its uses.
And people who are looking for low WAL volume ought to be stretching
out their checkpoint intervals anyway.

regards, tom lane


From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Hannu Krosing <hannu(at)skype(dot)net>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [PATCHES] WIP archive_timeout patch
Date: 2006-09-04 11:12:31
Message-ID: 1157368351.2749.52.camel@holly
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Fri, 2006-08-18 at 08:52 -0400, Tom Lane wrote:
> Simon Riggs <simon(at)2ndquadrant(dot)com> writes:
> > On Thu, 2006-08-17 at 19:11 -0400, Tom Lane wrote:
> >> I noticed a minor annoyance while testing: when the system is completely
> >> idle, you get a forced segment switch every checkpoint_timeout seconds,
> >> even though there is nothing useful to log. The checkpoint code is
> >> smart enough not to do a checkpoint if nothing has happened since the
> >> last one, and the xlog switch code is smart enough not to do a switch
> >> if nothing has happened since the last one ... but they aren't talking
> >> to each other and so each one's change looks like "something happened"
> >> to the other one.
>
> > I noticed that minor annoyance and understood that I had fixed it before
> > submitting. That was the reason for putting the code in bgwriter to
> > check whether the pointer had moved before attempting the switch...
> > perhaps that functionality has been removed?
>
> No, the original form of the patch was equally vulnerable. AFAICS the
> only way to prevent this would be for XLogRequestSwitch (or really
> XLogInsert, which does the heavy lifting for this) to suppress a switch
> if the current segment is empty *or* contains only a checkpoint WAL
> record. Basically it'd have to pretend the checkpoint record is not
> there. This is doable but seems a bit weird --- in particular, that
> would mean that pg_switch_xlog sometimes returns a pointer less than
> pg_current_xlog_location, which might confuse backup scripts.
>
> On the whole I'm leaning towards not changing it. As Florian mentioned,
> guaranteed segment-every-checkpoint isn't completely without its uses.
> And people who are looking for low WAL volume ought to be stretching
> out their checkpoint intervals anyway.

Agreed.

--
Simon Riggs
EnterpriseDB http://www.enterprisedb.com