Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1981527

Browse files
committed
Improve LOCK_DEBUG logging code for LWLocks.
1 parentce286ff commit1981527

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

‎src/backend/storage/lmgr/lwlock.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Portions Copyright (c) 1994, Regents of the University of California
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lwlock.c,v 1.4 2001/12/10 21:13:50 tgl Exp $
18+
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lwlock.c,v 1.5 2001/12/28 23:26:04 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -64,16 +64,25 @@ static LWLockId held_lwlocks[MAX_SIMUL_LWLOCKS];
6464
boolTrace_lwlocks= false;
6565

6666
inlinestaticvoid
67-
PRINT_LWDEBUG(constchar*where,LWLockIdlockid,constLWLock*lock)
67+
PRINT_LWDEBUG(constchar*where,LWLockIdlockid,constvolatileLWLock*lock)
6868
{
6969
if (Trace_lwlocks)
7070
elog(DEBUG,"%s(%d): excl %d shared %d head %p",
7171
where, (int)lockid,
7272
(int)lock->exclusive,lock->shared,lock->head);
7373
}
7474

75+
inlinestaticvoid
76+
LOG_LWDEBUG(constchar*where,LWLockIdlockid,constchar*msg)
77+
{
78+
if (Trace_lwlocks)
79+
elog(DEBUG,"%s(%d): %s",
80+
where, (int)lockid,msg);
81+
}
82+
7583
#else/* not LOCK_DEBUG */
7684
#definePRINT_LWDEBUG(a,b,c)
85+
#defineLOG_LWDEBUG(a,b,c)
7786
#endif/* LOCK_DEBUG */
7887

7988

@@ -265,6 +274,8 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode)
265274
* received, so that the lock manager or signal manager will see
266275
* the received signal when it next waits.
267276
*/
277+
LOG_LWDEBUG("LWLockAcquire",lockid,"waiting");
278+
268279
for (;;)
269280
{
270281
/* "false" means cannot accept cancel/die interrupt here. */
@@ -274,6 +285,8 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode)
274285
extraWaits++;
275286
}
276287

288+
LOG_LWDEBUG("LWLockAcquire",lockid,"awakened");
289+
277290
/*
278291
* The awakener already updated the lock struct's state, so we
279292
* don't need to do anything more to it. Just need to fix the
@@ -352,6 +365,7 @@ LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode)
352365
{
353366
/* Failed to get lock, so release interrupt holdoff */
354367
RESUME_INTERRUPTS();
368+
LOG_LWDEBUG("LWLockConditionalAcquire",lockid,"failed");
355369
}
356370
else
357371
{
@@ -448,6 +462,7 @@ LWLockRelease(LWLockId lockid)
448462
*/
449463
while (head!=NULL)
450464
{
465+
LOG_LWDEBUG("LWLockRelease",lockid,"release waiter");
451466
proc=head;
452467
head=proc->lwWaitLink;
453468
proc->lwWaitLink=NULL;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp