Unix Technical Forum

Minor fix in lwlock.c

This is a discussion on Minor fix in lwlock.c within the Pgsql Patches forums, part of the PostgreSQL category; --> Actually, on further thought, there's a really simple solution that we've used elsewhere: make sure you have the resource ...


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

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 04-18-2008, 12:13 AM
Tom Lane
 
Posts: n/a
Default Re: Minor fix in lwlock.c

Actually, on further thought, there's a really simple solution that
we've used elsewhere: make sure you have the resource you need *before*
you get into the critical section of code. I've applied the attached
revised patch.

regards, tom lane

*** src/backend/storage/lmgr/lwlock.c.orig Fri Dec 31 17:46:10 2004
--- src/backend/storage/lmgr/lwlock.c Fri Apr 8 10:14:04 2005
***************
*** 213,218 ****
--- 213,222 ----
*/
Assert(!(proc == NULL && IsUnderPostmaster));

+ /* Ensure we will have room to remember the lock */
+ if (num_held_lwlocks >= MAX_SIMUL_LWLOCKS)
+ elog(ERROR, "too many LWLocks taken");
+
/*
* Lock out cancel/die interrupts until we exit the code section
* protected by the LWLock. This ensures that interrupts will not
***************
*** 328,334 ****
SpinLockRelease_NoHoldoff(&lock->mutex);

/* Add lock to list of locks held by this backend */
- Assert(num_held_lwlocks < MAX_SIMUL_LWLOCKS);
held_lwlocks[num_held_lwlocks++] = lockid;

/*
--- 332,337 ----
***************
*** 353,358 ****
--- 356,365 ----

PRINT_LWDEBUG("LWLockConditionalAcquire", lockid, lock);

+ /* Ensure we will have room to remember the lock */
+ if (num_held_lwlocks >= MAX_SIMUL_LWLOCKS)
+ elog(ERROR, "too many LWLocks taken");
+
/*
* Lock out cancel/die interrupts until we exit the code section
* protected by the LWLock. This ensures that interrupts will not
***************
*** 397,403 ****
else
{
/* Add lock to list of locks held by this backend */
- Assert(num_held_lwlocks < MAX_SIMUL_LWLOCKS);
held_lwlocks[num_held_lwlocks++] = lockid;
}

--- 404,409 ----

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 04-18-2008, 12:13 AM
Qingqing Zhou
 
Posts: n/a
Default Re: Minor fix in lwlock.c


"Tom Lane" <tgl@sss.pgh.pa.us> writes
> Actually, on further thought, there's a really simple solution that
> we've used elsewhere: make sure you have the resource you need *before*
> you get into the critical section of code. I've applied the attached
> revised patch.
>


Oh, that's the one - why didn't think of it at the first time? :-)

Regards,
Qingqing


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 07:19 PM.


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