diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2001-12-28 23:26:04 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2001-12-28 23:26:04 +0000 |
commit | 198152730b83e591ae27f7568c6a737f71bdacbd (patch) | |
tree | a739045a5338e8392976c2f97f6e568d6ea699db | |
parent | ce286ff6b5f1be2b84734d4b3d16fd7e8bed00a5 (diff) | |
download | postgresql-198152730b83e591ae27f7568c6a737f71bdacbd.tar.gz postgresql-198152730b83e591ae27f7568c6a737f71bdacbd.zip |
Improve LOCK_DEBUG logging code for LWLocks.
-rw-r--r-- | src/backend/storage/lmgr/lwlock.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c index 00fae5438e0..98eead9558a 100644 --- a/src/backend/storage/lmgr/lwlock.c +++ b/src/backend/storage/lmgr/lwlock.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lwlock.c,v 1.4 2001/12/10 21:13:50 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lwlock.c,v 1.5 2001/12/28 23:26:04 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -64,7 +64,7 @@ static LWLockId held_lwlocks[MAX_SIMUL_LWLOCKS]; bool Trace_lwlocks = false; inline static void -PRINT_LWDEBUG(const char *where, LWLockId lockid, const LWLock *lock) +PRINT_LWDEBUG(const char *where, LWLockId lockid, const volatile LWLock *lock) { if (Trace_lwlocks) elog(DEBUG, "%s(%d): excl %d shared %d head %p", @@ -72,8 +72,17 @@ PRINT_LWDEBUG(const char *where, LWLockId lockid, const LWLock *lock) (int) lock->exclusive, lock->shared, lock->head); } +inline static void +LOG_LWDEBUG(const char *where, LWLockId lockid, const char *msg) +{ + if (Trace_lwlocks) + elog(DEBUG, "%s(%d): %s", + where, (int) lockid, msg); +} + #else /* not LOCK_DEBUG */ #define PRINT_LWDEBUG(a,b,c) +#define LOG_LWDEBUG(a,b,c) #endif /* LOCK_DEBUG */ @@ -265,6 +274,8 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode) * received, so that the lock manager or signal manager will see * the received signal when it next waits. */ + LOG_LWDEBUG("LWLockAcquire", lockid, "waiting"); + for (;;) { /* "false" means cannot accept cancel/die interrupt here. */ @@ -274,6 +285,8 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode) extraWaits++; } + LOG_LWDEBUG("LWLockAcquire", lockid, "awakened"); + /* * The awakener already updated the lock struct's state, so we * don't need to do anything more to it. Just need to fix the @@ -352,6 +365,7 @@ LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode) { /* Failed to get lock, so release interrupt holdoff */ RESUME_INTERRUPTS(); + LOG_LWDEBUG("LWLockConditionalAcquire", lockid, "failed"); } else { @@ -448,6 +462,7 @@ LWLockRelease(LWLockId lockid) */ while (head != NULL) { + LOG_LWDEBUG("LWLockRelease", lockid, "release waiter"); proc = head; head = proc->lwWaitLink; proc->lwWaitLink = NULL; |