mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
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 recent report from Litao Wu makes me wonder whether it is ever possible for us to drop a buffer and forget to release its cntx_lock. The Assert does not fire in the regression tests, but that proves little ...
This commit is contained in:
parent
8d64b56206
commit
e6cba71503
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.169 2004/05/31 20:31:33 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.170 2004/06/11 16:43:23 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -611,7 +611,12 @@ UnpinBuffer(BufferDesc *buf)
|
|||||||
Assert(PrivateRefCount[b] > 0);
|
Assert(PrivateRefCount[b] > 0);
|
||||||
PrivateRefCount[b]--;
|
PrivateRefCount[b]--;
|
||||||
if (PrivateRefCount[b] == 0)
|
if (PrivateRefCount[b] == 0)
|
||||||
|
{
|
||||||
buf->refcount--;
|
buf->refcount--;
|
||||||
|
/* I'd better not still hold any locks on the buffer */
|
||||||
|
Assert(!LWLockHeldByMe(buf->cntx_lock));
|
||||||
|
Assert(!LWLockHeldByMe(buf->io_in_progress_lock));
|
||||||
|
}
|
||||||
|
|
||||||
if ((buf->flags & BM_PIN_COUNT_WAITER) != 0 &&
|
if ((buf->flags & BM_PIN_COUNT_WAITER) != 0 &&
|
||||||
buf->refcount == 1)
|
buf->refcount == 1)
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.19 2003/12/20 17:31:21 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.20 2004/06/11 16:43:24 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -519,3 +519,23 @@ LWLockReleaseAll(void)
|
|||||||
LWLockRelease(held_lwlocks[num_held_lwlocks - 1]);
|
LWLockRelease(held_lwlocks[num_held_lwlocks - 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* LWLockHeldByMe - test whether my process currently holds a lock
|
||||||
|
*
|
||||||
|
* This is meant as debug support only. We do not distinguish whether the
|
||||||
|
* lock is held shared or exclusive.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
LWLockHeldByMe(LWLockId lockid)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < num_held_lwlocks; i++)
|
||||||
|
{
|
||||||
|
if (held_lwlocks[i] == lockid)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/storage/lwlock.h,v 1.11 2004/05/31 03:48:10 tgl Exp $
|
* $PostgreSQL: pgsql/src/include/storage/lwlock.h,v 1.12 2004/06/11 16:43:24 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -62,6 +62,7 @@ extern void LWLockAcquire(LWLockId lockid, LWLockMode mode);
|
|||||||
extern bool LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode);
|
extern bool LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode);
|
||||||
extern void LWLockRelease(LWLockId lockid);
|
extern void LWLockRelease(LWLockId lockid);
|
||||||
extern void LWLockReleaseAll(void);
|
extern void LWLockReleaseAll(void);
|
||||||
|
extern bool LWLockHeldByMe(LWLockId lockid);
|
||||||
|
|
||||||
extern int NumLWLocks(void);
|
extern int NumLWLocks(void);
|
||||||
extern int LWLockShmemSize(void);
|
extern int LWLockShmemSize(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user