Unix Technical Forum

Fix CheckpointStartLock starvation

This is a discussion on Fix CheckpointStartLock starvation within the Pgsql Patches forums, part of the PostgreSQL category; --> On a busy system, checkpoint could be starved while queuing for the CheckpointStartLock. To avoid that, get rid of ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Patches

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-18-2008, 10:51 AM
Heikki Linnakangas
 
Posts: n/a
Default Fix CheckpointStartLock starvation

On a busy system, checkpoint could be starved while queuing for the
CheckpointStartLock. To avoid that, get rid of CheckpointStartLock and
instead set a flag in PGPROC struct when a commit starts. After
computing the REDO ptr, checkpoint waits for all backends that had that
flag set to finish their commits. This eliminates the same race
condition the CheckpointStartLock was there for, without the risk of
starvation.

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


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-18-2008, 10:51 AM
Tom Lane
 
Posts: n/a
Default Re: Fix CheckpointStartLock starvation

Heikki Linnakangas <heikki@enterprisedb.com> writes:
> On a busy system, checkpoint could be starved while queuing for the
> CheckpointStartLock. To avoid that, get rid of CheckpointStartLock and
> instead set a flag in PGPROC struct when a commit starts. After
> computing the REDO ptr, checkpoint waits for all backends that had that
> flag set to finish their commits. This eliminates the same race
> condition the CheckpointStartLock was there for, without the risk of
> starvation.


Applied with some revisions --- I did not see the point of forcing
checkpoint to wait till the transaction was fully out of its commit;
we only need it to wait till clog is updated. The procarray code
seemed overly complicated too.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-18-2008, 10:51 AM
Heikki Linnakangas
 
Posts: n/a
Default Re: Fix CheckpointStartLock starvation

Tom Lane wrote:
> Heikki Linnakangas <heikki@enterprisedb.com> writes:
>> On a busy system, checkpoint could be starved while queuing for the
>> CheckpointStartLock. To avoid that, get rid of CheckpointStartLock and
>> instead set a flag in PGPROC struct when a commit starts. After
>> computing the REDO ptr, checkpoint waits for all backends that had that
>> flag set to finish their commits. This eliminates the same race
>> condition the CheckpointStartLock was there for, without the risk of
>> starvation.

>
> Applied with some revisions --- I did not see the point of forcing
> checkpoint to wait till the transaction was fully out of its commit;
> we only need it to wait till clog is updated.


Thanks! I'll rerun my test with this.

There was no particular reason to delay, but I figured it doesn't really
matter either way since checkpoints are not in a hurry.

> The procarray code seemed overly complicated too.


Yeah, it was a bit ugly. I wanted to doing the O(n^2) looping while
holding the ProcArrayLock. I doubt it's a problem in practice since it's
only done during a checkpoint and n should be small, but I'll stick to
that excuse.

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

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:55 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com