mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
Add debug check function LWLockHeldByMeInMode()
Tests whether my process holds a lock in given mode. Add initial usage in MarkBufferDirty(). Thomas Munro
This commit is contained in:
parent
ec03f4121c
commit
016abf1fb8
@ -1460,8 +1460,8 @@ MarkBufferDirty(Buffer buffer)
|
|||||||
bufHdr = GetBufferDescriptor(buffer - 1);
|
bufHdr = GetBufferDescriptor(buffer - 1);
|
||||||
|
|
||||||
Assert(BufferIsPinned(buffer));
|
Assert(BufferIsPinned(buffer));
|
||||||
/* unfortunately we can't check if the lock is held exclusively */
|
Assert(LWLockHeldByMeInMode(BufferDescriptorGetContentLock(bufHdr),
|
||||||
Assert(LWLockHeldByMe(BufferDescriptorGetContentLock(bufHdr)));
|
LW_EXCLUSIVE));
|
||||||
|
|
||||||
old_buf_state = pg_atomic_read_u32(&bufHdr->state);
|
old_buf_state = pg_atomic_read_u32(&bufHdr->state);
|
||||||
for (;;)
|
for (;;)
|
||||||
|
@ -1880,10 +1880,9 @@ LWLockReleaseAll(void)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* LWLockHeldByMe - test whether my process currently holds a lock
|
* LWLockHeldByMe - test whether my process holds a lock in any mode
|
||||||
*
|
*
|
||||||
* This is meant as debug support only. We currently do not distinguish
|
* This is meant as debug support only.
|
||||||
* whether the lock is held shared or exclusive.
|
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
LWLockHeldByMe(LWLock *l)
|
LWLockHeldByMe(LWLock *l)
|
||||||
@ -1897,3 +1896,21 @@ LWLockHeldByMe(LWLock *l)
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* LWLockHeldByMeInMode - test whether my process holds a lock in given mode
|
||||||
|
*
|
||||||
|
* This is meant as debug support only.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
LWLockHeldByMeInMode(LWLock *l, LWLockMode mode)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < num_held_lwlocks; i++)
|
||||||
|
{
|
||||||
|
if (held_lwlocks[i].lock == l && held_lwlocks[i].mode == mode)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -175,6 +175,7 @@ extern void LWLockRelease(LWLock *lock);
|
|||||||
extern void LWLockReleaseClearVar(LWLock *lock, uint64 *valptr, uint64 val);
|
extern void LWLockReleaseClearVar(LWLock *lock, uint64 *valptr, uint64 val);
|
||||||
extern void LWLockReleaseAll(void);
|
extern void LWLockReleaseAll(void);
|
||||||
extern bool LWLockHeldByMe(LWLock *lock);
|
extern bool LWLockHeldByMe(LWLock *lock);
|
||||||
|
extern bool LWLockHeldByMeInMode(LWLock *lock, LWLockMode mode);
|
||||||
|
|
||||||
extern bool LWLockWaitForVar(LWLock *lock, uint64 *valptr, uint64 oldval, uint64 *newval);
|
extern bool LWLockWaitForVar(LWLock *lock, uint64 *valptr, uint64 oldval, uint64 *newval);
|
||||||
extern void LWLockUpdateVar(LWLock *lock, uint64 *valptr, uint64 value);
|
extern void LWLockUpdateVar(LWLock *lock, uint64 *valptr, uint64 value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user