Index: src/backend/access/transam/xact.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/access/transam/xact.c,v retrieving revision 1.221 diff -c -r1.221 xact.c *** src/backend/access/transam/xact.c 20 Jun 2006 22:51:59 -0000 1.221 --- src/backend/access/transam/xact.c 27 Jun 2006 14:59:22 -0000 *************** *** 717,723 **** */ madeTCentries = (MyLastRecPtr.xrecoff != 0); if (madeTCentries) ! LWLockAcquire(CheckpointStartLock, LW_SHARED); /* * We only need to log the commit in XLOG if the transaction made any --- 717,723 ---- */ madeTCentries = (MyLastRecPtr.xrecoff != 0); if (madeTCentries) ! LWLockAcquire(CheckpointStartLock, LW_SHARED_QUEUED); /* * We only need to log the commit in XLOG if the transaction made any Index: src/backend/storage/lmgr/lwlock.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/storage/lmgr/lwlock.c,v retrieving revision 1.39 diff -c -r1.39 lwlock.c *** src/backend/storage/lmgr/lwlock.c 21 Apr 2006 16:45:12 -0000 1.39 --- src/backend/storage/lmgr/lwlock.c 27 Jun 2006 14:59:23 -0000 *************** *** 362,378 **** lock->releaseOK = true; /* If I can get the lock, do so quickly. */ ! if (mode == LW_EXCLUSIVE) ! { ! if (lock->exclusive == 0 && lock->shared == 0) ! { ! lock->exclusive++; ! mustwait = false; ! } ! else ! mustwait = true; ! } ! else { if (lock->exclusive == 0) { --- 362,368 ---- lock->releaseOK = true; /* If I can get the lock, do so quickly. */ ! if (mode == LW_SHARED) { if (lock->exclusive == 0) { *************** *** 382,387 **** --- 372,396 ---- else mustwait = true; } + else + { + if (mode == LW_EXCLUSIVE) /* LW_EXCLUSIVE */ + if (lock->exclusive == 0 && lock->shared == 0) + { + lock->exclusive++; + mustwait = false; + } + else + mustwait = true; + else /* LW_SHARED_QUEUED */ + if (lock->exclusive == 0 && lock->head == NULL) + { + lock->shared++; + mustwait = false; + } + else + mustwait = true; + } if (!mustwait) break; /* got the lock */ *************** *** 484,500 **** SpinLockAcquire(&lock->mutex); /* If I can get the lock, do so quickly. */ ! if (mode == LW_EXCLUSIVE) ! { ! if (lock->exclusive == 0 && lock->shared == 0) ! { ! lock->exclusive++; ! mustwait = false; ! } ! else ! mustwait = true; ! } ! else { if (lock->exclusive == 0) { --- 493,499 ---- SpinLockAcquire(&lock->mutex); /* If I can get the lock, do so quickly. */ ! if (mode == LW_SHARED) { if (lock->exclusive == 0) { *************** *** 504,509 **** --- 503,527 ---- else mustwait = true; } + else + { + if (mode == LW_EXCLUSIVE) /* LW_EXCLUSIVE */ + if (lock->exclusive == 0 && lock->shared == 0) + { + lock->exclusive++; + mustwait = false; + } + else + mustwait = true; + else /* LW_SHARED_QUEUED */ + if (lock->exclusive == 0 && lock->head == NULL) + { + lock->shared++; + mustwait = false; + } + else + mustwait = true; + } /* We are done updating shared state of the lock itself. */ SpinLockRelease(&lock->mutex); *************** *** 622,627 **** --- 640,646 ---- } + /* * LWLockReleaseAll - release all currently-held locks * Index: src/include/storage/lwlock.h =================================================================== RCS file: /projects/cvsroot/pgsql/src/include/storage/lwlock.h,v retrieving revision 1.28 diff -c -r1.28 lwlock.h *** src/include/storage/lwlock.h 8 May 2006 00:00:17 -0000 1.28 --- src/include/storage/lwlock.h 27 Jun 2006 14:59:24 -0000 *************** *** 57,63 **** typedef enum LWLockMode { LW_EXCLUSIVE, ! LW_SHARED } LWLockMode; --- 57,64 ---- typedef enum LWLockMode { LW_EXCLUSIVE, ! LW_SHARED, ! LW_SHARED_QUEUED } LWLockMode;