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

Commit064466a

Browse files
committed
From: Massimo Dal Zotto <dz@cs.unitn.it>
Subject: [HACKERS] lock debug traceThis is an update to my previous patches for lock debugging, already appliedto the current sources. It adds some improvements in the output messages andsome more output in WaitOnLock(). I have used with success to trace a nastydeadlock condition on pg_listener.
1 parentc4bf011 commit064466a

File tree

1 file changed

+25
-11
lines changed
  • src/backend/storage/lmgr

1 file changed

+25
-11
lines changed

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

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.8 1997/02/14 04:52:59 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.9 1997/03/15 01:23:58 scrappy Exp $
1111
*
1212
* NOTES
1313
* Outside modules can create a lock table and acquire/release
@@ -54,28 +54,41 @@
5454

5555
#defineLOCK_PRINT(where,tag,type)
5656
#defineLOCK_DUMP(where,lock,type)
57+
#defineLOCK_DUMP_AUX(where,lock,type)
5758
#defineXID_PRINT(where,xidentP)
5859

5960
#else/* LOCK_MGR_DEBUG */
6061

6162
intlockDebug=0;
63+
unsignedintlock_debug_oid_min=BootstrapObjectIdData;
64+
staticchar*lock_types[]= {
65+
"NONE",
66+
"WRITE",
67+
"READ",
68+
"WRITE INTENT",
69+
"READ INTENT",
70+
"EXTEND"
71+
};
6272

6373
#defineLOCK_PRINT(where,tag,type)\
64-
if ((lockDebug >= 1) && (tag->relId >=BootstrapObjectIdData)) \
74+
if ((lockDebug >= 1) && (tag->relId >=lock_debug_oid_min)) \
6575
elog(DEBUG, \
66-
"%s: pid (%d) rel (%d) dbid (%d) tid (%d,%d) type (%d)",where, \
76+
"%s: pid (%d) rel (%d) dbid (%d) tid (%d,%d) type (%s)",where, \
6777
getpid(),\
6878
tag->relId, tag->dbId, \
6979
((tag->tupleId.ip_blkid.bi_hi<<16)+\
7080
tag->tupleId.ip_blkid.bi_lo),\
7181
tag->tupleId.ip_posid, \
72-
type);
82+
lock_types[type])
7383

7484
#defineLOCK_DUMP(where,lock,type)\
75-
if ((lockDebug >= 1) && (lock->tag.relId >= BootstrapObjectIdData)) \
85+
if ((lockDebug >= 1) && (lock->tag.relId >= lock_debug_oid_min)) \
86+
LOCK_DUMP_AUX(where,lock,type)
87+
88+
#defineLOCK_DUMP_AUX(where,lock,type)\
7689
elog(DEBUG, \
7790
"%s: pid (%d) rel (%d) dbid (%d) tid (%d,%d) nHolding (%d) "\
78-
"holders (%d,%d,%d,%d,%d) type (%d)",where, \
91+
"holders (%d,%d,%d,%d,%d) type (%s)",where, \
7992
getpid(),\
8093
lock->tag.relId, lock->tag.dbId, \
8194
((lock->tag.tupleId.ip_blkid.bi_hi<<16)+\
@@ -87,12 +100,12 @@ int lockDebug = 0;
87100
lock->holders[3],\
88101
lock->holders[4],\
89102
lock->holders[5],\
90-
type);
103+
lock_types[type])
91104

92105
#defineXID_PRINT(where,xidentP)\
93106
if ((lockDebug >= 2) && \
94107
(((LOCK *)MAKE_PTR(xidentP->tag.lock))->tag.relId \
95-
>=BootstrapObjectIdData)) \
108+
>=lock_debug_oid_min)) \
96109
elog(DEBUG,\
97110
"%s: pid (%d) xid (%d) pid (%d) lock (%x) nHolding (%d) "\
98111
"holders (%d,%d,%d,%d,%d)",\
@@ -106,7 +119,7 @@ int lockDebug = 0;
106119
xidentP->holders[2],\
107120
xidentP->holders[3],\
108121
xidentP->holders[4],\
109-
xidentP->holders[5]);
122+
xidentP->holders[5])
110123

111124
#endif/* LOCK_MGR_DEBUG */
112125

@@ -755,7 +768,7 @@ WaitOnLock(LOCKTAB *ltable, LockTableId tableId, LOCK *lock, LOCKT lockt)
755768
* will not be true if/when people can be deleted from
756769
* the queue by a SIGINT or something.
757770
*/
758-
LOCK_DUMP("WaitOnLock: sleeping on lock",lock,lockt);
771+
LOCK_DUMP_AUX("WaitOnLock: sleeping on lock",lock,lockt);
759772
if (ProcSleep(waitQueue,
760773
ltable->ctl->masterLock,
761774
lockt,
@@ -770,11 +783,12 @@ WaitOnLock(LOCKTAB *ltable, LockTableId tableId, LOCK *lock, LOCKT lockt)
770783
*/
771784
lock->nHolding--;
772785
lock->holders[lockt]--;
773-
LOCK_DUMP("WaitOnLock: aborting on lock",lock,lockt);
786+
LOCK_DUMP_AUX("WaitOnLock: aborting on lock",lock,lockt);
774787
SpinRelease(ltable->ctl->masterLock);
775788
elog(WARN,"WaitOnLock: error on wakeup - Aborting this transaction");
776789
}
777790

791+
LOCK_DUMP_AUX("WaitOnLock: wakeup on lock",lock,lockt);
778792
return(STATUS_OK);
779793
}
780794

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp