Commit dea6ed2c authored by Heikki Linnakangas's avatar Heikki Linnakangas

Fix build with LWLOCK_STATS or dtrace.

Also fix the name of the dtrace probe for LWLockAcquireOrWait(). The
function was renamed from LWLockWaitUntilFree to LWLockAqcuireOrWait, but
the dtrace probe was neglected.

Pointed out by Andres Freund and the buildfarm.
parent 1494931d
...@@ -859,13 +859,13 @@ LWLockAcquireOrWait(LWLock *l, LWLockMode mode) ...@@ -859,13 +859,13 @@ LWLockAcquireOrWait(LWLock *l, LWLockMode mode)
/* Failed to get lock, so release interrupt holdoff */ /* Failed to get lock, so release interrupt holdoff */
RESUME_INTERRUPTS(); RESUME_INTERRUPTS();
LOG_LWDEBUG("LWLockAcquireOrWait", T_NAME(l), T_ID(l), "failed"); LOG_LWDEBUG("LWLockAcquireOrWait", T_NAME(l), T_ID(l), "failed");
TRACE_POSTGRESQL_LWLOCK_WAIT_UNTIL_FREE_FAIL(T_NAME(l), T_ID(l), mode); TRACE_POSTGRESQL_LWLOCK_ACQUIRE_OR_WAIT_FAIL(T_NAME(l), T_ID(l), mode);
} }
else else
{ {
/* Add lock to list of locks held by this backend */ /* Add lock to list of locks held by this backend */
held_lwlocks[num_held_lwlocks++] = l; held_lwlocks[num_held_lwlocks++] = l;
TRACE_POSTGRESQL_LWLOCK_WAIT_UNTIL_FREE(T_NAME(l), T_ID(l), mode); TRACE_POSTGRESQL_LWLOCK_ACQUIRE_OR_WAIT(T_NAME(l), T_ID(l), mode);
} }
return !mustwait; return !mustwait;
...@@ -897,6 +897,15 @@ LWLockWaitForVar(LWLock *l, uint64 *valptr, uint64 oldval, uint64 *newval) ...@@ -897,6 +897,15 @@ LWLockWaitForVar(LWLock *l, uint64 *valptr, uint64 oldval, uint64 *newval)
PGPROC *proc = MyProc; PGPROC *proc = MyProc;
int extraWaits = 0; int extraWaits = 0;
bool result = false; bool result = false;
#ifdef LWLOCK_STATS
lwlock_stats *lwstats;
#endif
PRINT_LWDEBUG("LWLockWaitForVar", lock);
#ifdef LWLOCK_STATS
lwstats = get_lwlock_stats_entry(l);
#endif /* LWLOCK_STATS */
/* /*
* Quick test first to see if it the slot is free right now. * Quick test first to see if it the slot is free right now.
...@@ -986,7 +995,7 @@ LWLockWaitForVar(LWLock *l, uint64 *valptr, uint64 oldval, uint64 *newval) ...@@ -986,7 +995,7 @@ LWLockWaitForVar(LWLock *l, uint64 *valptr, uint64 oldval, uint64 *newval)
lwstats->block_count++; lwstats->block_count++;
#endif #endif
TRACE_POSTGRESQL_LWLOCK_WAIT_START(T_NAME(l), T_ID(l), mode); TRACE_POSTGRESQL_LWLOCK_WAIT_START(T_NAME(l), T_ID(l), LW_EXCLUSIVE);
for (;;) for (;;)
{ {
...@@ -997,7 +1006,7 @@ LWLockWaitForVar(LWLock *l, uint64 *valptr, uint64 oldval, uint64 *newval) ...@@ -997,7 +1006,7 @@ LWLockWaitForVar(LWLock *l, uint64 *valptr, uint64 oldval, uint64 *newval)
extraWaits++; extraWaits++;
} }
TRACE_POSTGRESQL_LWLOCK_WAIT_DONE(T_NAME(l), T_ID(l), mode); TRACE_POSTGRESQL_LWLOCK_WAIT_DONE(T_NAME(l), T_ID(l), LW_EXCLUSIVE);
LOG_LWDEBUG("LWLockWaitForVar", T_NAME(l), T_ID(l), "awakened"); LOG_LWDEBUG("LWLockWaitForVar", T_NAME(l), T_ID(l), "awakened");
...@@ -1007,7 +1016,7 @@ LWLockWaitForVar(LWLock *l, uint64 *valptr, uint64 oldval, uint64 *newval) ...@@ -1007,7 +1016,7 @@ LWLockWaitForVar(LWLock *l, uint64 *valptr, uint64 oldval, uint64 *newval)
/* We are done updating shared state of the lock itself. */ /* We are done updating shared state of the lock itself. */
SpinLockRelease(&lock->mutex); SpinLockRelease(&lock->mutex);
TRACE_POSTGRESQL_LWLOCK_ACQUIRE(T_NAME(l), T_ID(l), mode); TRACE_POSTGRESQL_LWLOCK_ACQUIRE(T_NAME(l), T_ID(l), LW_EXCLUSIVE);
/* /*
* Fix the process wait semaphore's count for any absorbed wakeups. * Fix the process wait semaphore's count for any absorbed wakeups.
......
...@@ -34,8 +34,8 @@ provider postgresql { ...@@ -34,8 +34,8 @@ provider postgresql {
probe lwlock__wait__done(const char *, int, LWLockMode); probe lwlock__wait__done(const char *, int, LWLockMode);
probe lwlock__condacquire(const char *, int, LWLockMode); probe lwlock__condacquire(const char *, int, LWLockMode);
probe lwlock__condacquire__fail(const char *, int, LWLockMode); probe lwlock__condacquire__fail(const char *, int, LWLockMode);
probe lwlock__wait__until__free(const char *, int, LWLockMode); probe lwlock__acquire__or__wait(const char *, int, LWLockMode);
probe lwlock__wait__until__free__fail(const char *, int, LWLockMode); probe lwlock__acquire__or__wait__fail(const char *, int, LWLockMode);
probe lock__wait__start(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, LOCKMODE); probe lock__wait__start(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, LOCKMODE);
probe lock__wait__done(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, LOCKMODE); probe lock__wait__done(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, LOCKMODE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment