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

Commite6cba71

Browse files
committed
Add some code to Assert that when we release pin on a buffer, we are
not holding the buffer's cntx_lock or io_in_progress_lock. A recentreport from Litao Wu makes me wonder whether it is ever possible forus to drop a buffer and forget to release its cntx_lock. The Assertdoes not fire in the regression tests, but that proves little ...
1 parent8d64b56 commite6cba71

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.169 2004/05/31 20:31:33 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.170 2004/06/11 16:43:23 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -611,7 +611,12 @@ UnpinBuffer(BufferDesc *buf)
611611
Assert(PrivateRefCount[b]>0);
612612
PrivateRefCount[b]--;
613613
if (PrivateRefCount[b]==0)
614+
{
614615
buf->refcount--;
616+
/* I'd better not still hold any locks on the buffer */
617+
Assert(!LWLockHeldByMe(buf->cntx_lock));
618+
Assert(!LWLockHeldByMe(buf->io_in_progress_lock));
619+
}
615620

616621
if ((buf->flags&BM_PIN_COUNT_WAITER)!=0&&
617622
buf->refcount==1)

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

Lines changed: 21 additions & 1 deletion
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-
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.19 2003/12/20 17:31:21 momjian Exp $
18+
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.20 2004/06/11 16:43:24 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -519,3 +519,23 @@ LWLockReleaseAll(void)
519519
LWLockRelease(held_lwlocks[num_held_lwlocks-1]);
520520
}
521521
}
522+
523+
524+
/*
525+
* LWLockHeldByMe - test whether my process currently holds a lock
526+
*
527+
* This is meant as debug support only. We do not distinguish whether the
528+
* lock is held shared or exclusive.
529+
*/
530+
bool
531+
LWLockHeldByMe(LWLockIdlockid)
532+
{
533+
inti;
534+
535+
for (i=0;i<num_held_lwlocks;i++)
536+
{
537+
if (held_lwlocks[i]==lockid)
538+
return true;
539+
}
540+
return false;
541+
}

‎src/include/storage/lwlock.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/storage/lwlock.h,v 1.11 2004/05/31 03:48:10 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/storage/lwlock.h,v 1.12 2004/06/11 16:43:24 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -62,6 +62,7 @@ extern void LWLockAcquire(LWLockId lockid, LWLockMode mode);
6262
externboolLWLockConditionalAcquire(LWLockIdlockid,LWLockModemode);
6363
externvoidLWLockRelease(LWLockIdlockid);
6464
externvoidLWLockReleaseAll(void);
65+
externboolLWLockHeldByMe(LWLockIdlockid);
6566

6667
externintNumLWLocks(void);
6768
externintLWLockShmemSize(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp