Minor fix in lwlock.c - Mailing list pgsql-patches

From Qingqing Zhou
Subject Minor fix in lwlock.c
Date
Msg-id d34pvh$2tbh$1@news.hub.org
Whole thread Raw
Responses Re: Minor fix in lwlock.c
List pgsql-patches
The chance that num_held_lwlocks is beyond MAX_SIMUL_LWLOCKS is similar to
the chance that failed to grasp a spinlock in 1 minute, so they should be
treated in the same way. This is mainly to prevent programming error (e.g.,
forget to release the LWLocks).

Regards,
Qingqing

---

Index: lwlock.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/storage/lmgr/lwlock.c,v
retrieving revision 1.25
diff -c -r1.25 lwlock.c
*** lwlock.c    31 Dec 2004 22:01:05 -0000      1.25
--- lwlock.c    8 Apr 2005 02:19:31 -0000
***************
*** 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;

        /*
--- 328,335 ----
        SpinLockRelease_NoHoldoff(&lock->mutex);

        /* Add lock to list of locks held by this backend */
!       if (num_held_lwlocks >= MAX_SIMUL_LWLOCKS)
!               elog(FATAL, "Too many LWLocks");
        held_lwlocks[num_held_lwlocks++] = lockid;

        /*
***************
*** 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;
        }

--- 398,405 ----
        else
        {
                /* Add lock to list of locks held by this backend */
!               if (num_held_lwlocks >= MAX_SIMUL_LWLOCKS)
!                       elog(FATAL, "Too many LWLocks");
                held_lwlocks[num_held_lwlocks++] = lockid;
        }



pgsql-patches by date:

Previous
From: Neil Conway
Date:
Subject: Re: add_missing_from = false
Next
From: Tom Lane
Date:
Subject: Re: Minor fix in lwlock.c