Hi,
The lwlock dtrace probes define LWLockMode as int, and the
TRACE_POSTGRESQL_LWLOCK methods are called using both a variable and
constant definition.
This leads to a mix of argument definitions depending on the call site,
as seen in probes.txt file.
A fix is to explicit cast 'mode' to int such that all call sites will
use the
argument #2 4 signed bytes
definition. Attached patch does this.
I have verified all dtraces probes for their type, and only the lock__
methods doesn't aligned with its actual types. However, that would
require a change to probes.d, and therefore PostgreSQL 11 material.
Depending on the feedback I can add this patch to the open item list in
order to fix it for PostgreSQL 10.
Best regards,
Jesper
>From d6f5c119c057c7ff8c84f88bb4122a1ca245a7d4 Mon Sep 17 00:00:00 2001
From: jesperpedersen <jesper.peder...@redhat.com>
Date: Tue, 18 Apr 2017 11:44:18 -0400
Subject: [PATCH] Explicit cast LWLockMode, which an enum, to int in order to
match the dtrace definition of the lwlock methods. Thereby all call sites
will have the same definition instead of a mix between signed and unsigned.
Author: Jesper Pedersen <jesper.peder...@redhat.com>
---
src/backend/storage/lmgr/lwlock.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c
index 3e13394..abf5fbb 100644
--- a/src/backend/storage/lmgr/lwlock.c
+++ b/src/backend/storage/lmgr/lwlock.c
@@ -1226,7 +1226,7 @@ LWLockAcquire(LWLock *lock, LWLockMode mode)
#endif
LWLockReportWaitStart(lock);
- TRACE_POSTGRESQL_LWLOCK_WAIT_START(T_NAME(lock), mode);
+ TRACE_POSTGRESQL_LWLOCK_WAIT_START(T_NAME(lock), (int)mode);
for (;;)
{
@@ -1248,7 +1248,7 @@ LWLockAcquire(LWLock *lock, LWLockMode mode)
}
#endif
- TRACE_POSTGRESQL_LWLOCK_WAIT_DONE(T_NAME(lock), mode);
+ TRACE_POSTGRESQL_LWLOCK_WAIT_DONE(T_NAME(lock), (int)mode);
LWLockReportWaitEnd();
LOG_LWDEBUG("LWLockAcquire", lock, "awakened");
@@ -1257,7 +1257,7 @@ LWLockAcquire(LWLock *lock, LWLockMode mode)
result = false;
}
- TRACE_POSTGRESQL_LWLOCK_ACQUIRE(T_NAME(lock), mode);
+ TRACE_POSTGRESQL_LWLOCK_ACQUIRE(T_NAME(lock), (int)mode);
/* Add lock to list of locks held by this backend */
held_lwlocks[num_held_lwlocks].lock = lock;
@@ -1308,14 +1308,14 @@ LWLockConditionalAcquire(LWLock *lock, LWLockMode mode)
RESUME_INTERRUPTS();
LOG_LWDEBUG("LWLockConditionalAcquire", lock, "failed");
- TRACE_POSTGRESQL_LWLOCK_CONDACQUIRE_FAIL(T_NAME(lock), mode);
+ TRACE_POSTGRESQL_LWLOCK_CONDACQUIRE_FAIL(T_NAME(lock), (int)mode);
}
else
{
/* Add lock to list of locks held by this backend */
held_lwlocks[num_held_lwlocks].lock = lock;
held_lwlocks[num_held_lwlocks++].mode = mode;
- TRACE_POSTGRESQL_LWLOCK_CONDACQUIRE(T_NAME(lock), mode);
+ TRACE_POSTGRESQL_LWLOCK_CONDACQUIRE(T_NAME(lock), (int)mode);
}
return !mustwait;
}
@@ -1387,7 +1387,7 @@ LWLockAcquireOrWait(LWLock *lock, LWLockMode mode)
#endif
LWLockReportWaitStart(lock);
- TRACE_POSTGRESQL_LWLOCK_WAIT_START(T_NAME(lock), mode);
+ TRACE_POSTGRESQL_LWLOCK_WAIT_START(T_NAME(lock), (int)mode);
for (;;)
{
@@ -1405,7 +1405,7 @@ LWLockAcquireOrWait(LWLock *lock, LWLockMode mode)
Assert(nwaiters < MAX_BACKENDS);
}
#endif
- TRACE_POSTGRESQL_LWLOCK_WAIT_DONE(T_NAME(lock), mode);
+ TRACE_POSTGRESQL_LWLOCK_WAIT_DONE(T_NAME(lock), (int)mode);
LWLockReportWaitEnd();
LOG_LWDEBUG("LWLockAcquireOrWait", lock, "awakened");
@@ -1435,7 +1435,7 @@ LWLockAcquireOrWait(LWLock *lock, LWLockMode mode)
/* Failed to get lock, so release interrupt holdoff */
RESUME_INTERRUPTS();
LOG_LWDEBUG("LWLockAcquireOrWait", lock, "failed");
- TRACE_POSTGRESQL_LWLOCK_ACQUIRE_OR_WAIT_FAIL(T_NAME(lock), mode);
+ TRACE_POSTGRESQL_LWLOCK_ACQUIRE_OR_WAIT_FAIL(T_NAME(lock), (int)mode);
}
else
{
@@ -1443,7 +1443,7 @@ LWLockAcquireOrWait(LWLock *lock, LWLockMode mode)
/* Add lock to list of locks held by this backend */
held_lwlocks[num_held_lwlocks].lock = lock;
held_lwlocks[num_held_lwlocks++].mode = mode;
- TRACE_POSTGRESQL_LWLOCK_ACQUIRE_OR_WAIT(T_NAME(lock), mode);
+ TRACE_POSTGRESQL_LWLOCK_ACQUIRE_OR_WAIT(T_NAME(lock), (int)mode);
}
return !mustwait;
--
2.7.4
/usr/local/bin/postgres postgresql:clog__checkpoint__start [sema 0xe2351a]
location #1 0x4fc706
argument #1 1 signed bytes @ 0
location #2 0x4fc72d
argument #1 1 signed bytes @ 1
/usr/local/bin/postgres postgresql:clog__checkpoint__done [sema 0xe2351c]
location #1 0x4fc725
argument #1 1 signed bytes @ 0
location #2 0x4fc74c
argument #1 1 signed bytes @ 1
/usr/local/bin/postgres postgresql:multixact__checkpoint__start [sema 0xe23522]
location #1 0x500d07
argument #1 1 signed bytes @ 0
location #2 0x500dbc
argument #1 1 signed bytes @ 1
/usr/local/bin/postgres postgresql:multixact__checkpoint__done [sema 0xe23524]
location #1 0x500d26
argument #1 1 signed bytes @ 0
location #2 0x500ddb
argument #1 1 signed bytes @ 1
/usr/local/bin/postgres postgresql:subtrans__checkpoint__start [sema 0xe2351e]
location #1 0x506bc0
argument #1 1 signed bytes @ 0
location #2 0x506bd8
argument #1 1 signed bytes @ 1
/usr/local/bin/postgres postgresql:subtrans__checkpoint__done [sema 0xe23520]
location #1 0x506bd0
argument #1 1 signed bytes @ 0
location #2 0x506be8
argument #1 1 signed bytes @ 1
/usr/local/bin/postgres postgresql:twophase__checkpoint__start [sema 0xe23526]
location #1 0x50a9db
/usr/local/bin/postgres postgresql:twophase__checkpoint__done [sema 0xe23528]
location #1 0x50aaeb
/usr/local/bin/postgres postgresql:transaction__start [sema 0xe234c8]
location #1 0x50d930
argument #1 4 unsigned bytes @ ax
/usr/local/bin/postgres postgresql:transaction__commit [sema 0xe234ca]
location #1 0x50db14
argument #1 4 unsigned bytes @ ax
/usr/local/bin/postgres postgresql:transaction__abort [sema 0xe234cc]
location #1 0x50e252
argument #1 4 unsigned bytes @ ax
/usr/local/bin/postgres postgresql:wal__switch [sema 0xe23534]
location #1 0x51202a
/usr/local/bin/postgres postgresql:wal__buffer__write__dirty__start [sema
0xe23536]
location #1 0x5132a1
/usr/local/bin/postgres postgresql:wal__buffer__write__dirty__done [sema
0xe23538]
location #1 0x5132df
/usr/local/bin/postgres postgresql:checkpoint__start [sema 0xe23516]
location #1 0x51f0e4
argument #1 4 signed bytes @ *(bp - 260)
/usr/local/bin/postgres postgresql:checkpoint__done [sema 0xe23518]
location #1 0x51f6bb
argument #1 4 signed bytes @ ax
argument #2 4 signed bytes @ dx
argument #3 4 signed bytes @ cx
argument #4 4 signed bytes @ si
argument #5 4 signed bytes @ di
/usr/local/bin/postgres postgresql:wal__insert [sema 0xe23532]
location #1 0x52790e
argument #1 1 unsigned bytes @ *(bp - 52)
argument #2 1 unsigned bytes @ *(bp - 56)
/usr/local/bin/postgres postgresql:statement__status [sema 0xe234f6]
location #1 0x7861b2
argument #1 8 unsigned bytes @ *(bp - 80)
/usr/local/bin/postgres postgresql:buffer__read__start [sema 0xe234fc]
location #1 0x7e0176
argument #1 4 signed bytes @ *(bp - 224)
argument #2 4 unsigned bytes @ *(bp - 228)
argument #3 4 unsigned bytes @ dx
argument #4 4 unsigned bytes @ cx
argument #5 4 unsigned bytes @ si
argument #6 4 signed bytes @ ax
argument #7 1 signed bytes @ *(bp - 50)
/usr/local/bin/postgres postgresql:buffer__read__done [sema 0xe234fe]
location #1 0x7e02e0
argument #1 4 signed bytes @ *(bp - 224)
argument #2 4 unsigned bytes @ *(bp - 228)
argument #3 4 unsigned bytes @ dx
argument #4 4 unsigned bytes @ cx
argument #5 4 unsigned bytes @ si
argument #6 4 signed bytes @ ax
argument #7 1 signed bytes @ *(bp - 50)
argument #8 1 signed bytes @ di
location #2 0x7e0abc
argument #1 4 signed bytes @ *(bp - 224)
argument #2 4 unsigned bytes @ *(bp - 228)
argument #3 4 unsigned bytes @ dx
argument #4 4 unsigned bytes @ cx
argument #5 4 unsigned bytes @ si
argument #6 4 signed bytes @ ax
argument #7 1 signed bytes @ *(bp - 50)
argument #8 1 signed bytes @ di
/usr/local/bin/postgres postgresql:buffer__write__dirty__start [sema 0xe23510]
location #1 0x7e0d5d
argument #1 4 signed bytes @ *(bp - 160)
argument #2 4 unsigned bytes @ *(bp - 164)
argument #3 4 unsigned bytes @ dx
argument #4 4 unsigned bytes @ cx
argument #5 4 unsigned bytes @ ax
/usr/local/bin/postgres postgresql:buffer__write__dirty__done [sema 0xe23512]
location #1 0x7e0dad
argument #1 4 signed bytes @ *(bp - 160)
argument #2 4 unsigned bytes @ *(bp - 164)
argument #3 4 unsigned bytes @ dx
argument #4 4 unsigned bytes @ cx
argument #5 4 unsigned bytes @ ax
/usr/local/bin/postgres postgresql:buffer__sync__start [sema 0xe2350a]
location #1 0x7e1a0e
argument #1 4 signed bytes @ ax
argument #2 4 signed bytes @ *(bp - 12)
/usr/local/bin/postgres postgresql:buffer__sync__written [sema 0xe2350c]
location #1 0x7e1c99
argument #1 4 signed bytes @ *(bp - 8)
/usr/local/bin/postgres postgresql:buffer__sync__done [sema 0xe2350e]
location #1 0x7e1d9b
argument #1 4 signed bytes @ ax
argument #2 4 signed bytes @ *(bp - 24)
argument #3 4 signed bytes @ *(bp - 12)
/usr/local/bin/postgres postgresql:buffer__checkpoint__start [sema 0xe23504]
location #1 0x7e2661
argument #1 4 signed bytes @ *(bp - 4)
/usr/local/bin/postgres postgresql:buffer__checkpoint__sync__start [sema
0xe23506]
location #1 0x7e2684
/usr/local/bin/postgres postgresql:buffer__checkpoint__done [sema 0xe23508]
location #1 0x7e2696
/usr/local/bin/postgres postgresql:buffer__flush__start [sema 0xe23500]
location #1 0x7e282e
argument #1 4 signed bytes @ dx
argument #2 4 unsigned bytes @ cx
argument #3 4 unsigned bytes @ si
argument #4 4 unsigned bytes @ di
argument #5 4 unsigned bytes @ ax
/usr/local/bin/postgres postgresql:buffer__flush__done [sema 0xe23502]
location #1 0x7e2a86
argument #1 4 signed bytes @ dx
argument #2 4 unsigned bytes @ cx
argument #3 4 unsigned bytes @ si
argument #4 4 unsigned bytes @ di
argument #5 4 unsigned bytes @ ax
/usr/local/bin/postgres postgresql:lock__wait__start [sema 0xe234de]
location #1 0x7fe9aa
argument #1 4 unsigned bytes @ dx
argument #2 4 unsigned bytes @ cx
argument #3 4 unsigned bytes @ si
argument #4 2 unsigned bytes @ di
argument #5 1 unsigned bytes @ ax
argument #6 4 signed bytes @ *(bp - 188)
/usr/local/bin/postgres postgresql:lock__wait__done [sema 0xe234e0]
location #1 0x7fe9f1
argument #1 4 unsigned bytes @ dx
argument #2 4 unsigned bytes @ cx
argument #3 4 unsigned bytes @ si
argument #4 2 unsigned bytes @ di
argument #5 1 unsigned bytes @ ax
argument #6 4 signed bytes @ *(bp - 188)
/usr/local/bin/postgres postgresql:deadlock__found [sema 0xe23514]
location #1 0x806382
/usr/local/bin/postgres postgresql:lwlock__wait__start [sema 0xe234d2]
location #1 0x8090aa
argument #1 8 unsigned bytes @ ax
argument #2 4 unsigned bytes @ *(bp - 44)
location #2 0x809359
argument #1 8 unsigned bytes @ ax
argument #2 4 unsigned bytes @ *(bp - 28)
location #3 0x8095e6
argument #1 8 unsigned bytes @ ax
argument #2 4 signed bytes @ 0
/usr/local/bin/postgres postgresql:lwlock__wait__done [sema 0xe234d4]
location #1 0x8090fe
argument #1 8 unsigned bytes @ ax
argument #2 4 unsigned bytes @ *(bp - 44)
location #2 0x809398
argument #1 8 unsigned bytes @ ax
argument #2 4 unsigned bytes @ *(bp - 28)
location #3 0x809625
argument #1 8 unsigned bytes @ ax
argument #2 4 signed bytes @ 0
/usr/local/bin/postgres postgresql:lwlock__acquire [sema 0xe234ce]
location #1 0x809129
argument #1 8 unsigned bytes @ ax
argument #2 4 unsigned bytes @ *(bp - 44)
location #2 0x80964c
argument #1 8 unsigned bytes @ ax
argument #2 4 signed bytes @ 0
/usr/local/bin/postgres postgresql:lwlock__condacquire__fail [sema 0xe234d8]
location #1 0x809221
argument #1 8 unsigned bytes @ ax
argument #2 4 unsigned bytes @ *(bp - 28)
/usr/local/bin/postgres postgresql:lwlock__condacquire [sema 0xe234d6]
location #1 0x80927a
argument #1 8 unsigned bytes @ ax
argument #2 4 unsigned bytes @ *(bp - 28)
/usr/local/bin/postgres postgresql:lwlock__acquire__or__wait__fail [sema
0xe234dc]
location #1 0x8093fb
argument #1 8 unsigned bytes @ ax
argument #2 4 unsigned bytes @ *(bp - 28)
/usr/local/bin/postgres postgresql:lwlock__acquire__or__wait [sema 0xe234da]
location #1 0x809454
argument #1 8 unsigned bytes @ ax
argument #2 4 unsigned bytes @ *(bp - 28)
/usr/local/bin/postgres postgresql:lwlock__release [sema 0xe234d0]
location #1 0x8099b4
argument #1 8 unsigned bytes @ ax
/usr/local/bin/postgres postgresql:smgr__md__read__start [sema 0xe2352a]
location #1 0x813855
argument #1 4 signed bytes @ *(bp - 92)
argument #2 4 unsigned bytes @ *(bp - 96)
argument #3 4 unsigned bytes @ dx
argument #4 4 unsigned bytes @ cx
argument #5 4 unsigned bytes @ si
argument #6 4 signed bytes @ ax
/usr/local/bin/postgres postgresql:smgr__md__read__done [sema 0xe2352c]
location #1 0x81393b
argument #1 4 signed bytes @ *(bp - 92)
argument #2 4 unsigned bytes @ *(bp - 96)
argument #3 4 unsigned bytes @ dx
argument #4 4 unsigned bytes @ cx
argument #5 4 unsigned bytes @ si
argument #6 4 signed bytes @ ax
argument #7 4 signed bytes @ *(bp - 44)
argument #8 4 signed bytes @ 8192
/usr/local/bin/postgres postgresql:smgr__md__write__start [sema 0xe2352e]
location #1 0x813b06
argument #1 4 signed bytes @ *(bp - 60)
argument #2 4 unsigned bytes @ *(bp - 64)
argument #3 4 unsigned bytes @ dx
argument #4 4 unsigned bytes @ cx
argument #5 4 unsigned bytes @ si
argument #6 4 signed bytes @ ax
/usr/local/bin/postgres postgresql:smgr__md__write__done [sema 0xe23530]
location #1 0x813beb
argument #1 4 signed bytes @ *(bp - 60)
argument #2 4 unsigned bytes @ *(bp - 64)
argument #3 4 unsigned bytes @ dx
argument #4 4 unsigned bytes @ cx
argument #5 4 unsigned bytes @ si
argument #6 4 signed bytes @ ax
argument #7 4 signed bytes @ *(bp - 36)
argument #8 4 signed bytes @ 8192
/usr/local/bin/postgres postgresql:query__parse__start [sema 0xe234e2]
location #1 0x817fac
argument #1 8 unsigned bytes @ *(bp - 24)
/usr/local/bin/postgres postgresql:query__parse__done [sema 0xe234e4]
location #1 0x817fe2
argument #1 8 unsigned bytes @ *(bp - 24)
/usr/local/bin/postgres postgresql:query__rewrite__start [sema 0xe234e6]
location #1 0x818004
argument #1 8 unsigned bytes @ *(bp - 32)
location #2 0x81807f
argument #1 8 unsigned bytes @ *(bp - 48)
/usr/local/bin/postgres postgresql:query__rewrite__done [sema 0xe234e8]
location #1 0x81805c
argument #1 8 unsigned bytes @ *(bp - 32)
location #2 0x818138
argument #1 8 unsigned bytes @ *(bp - 48)
/usr/local/bin/postgres postgresql:query__plan__start [sema 0xe234ea]
location #1 0x818229
/usr/local/bin/postgres postgresql:query__plan__done [sema 0xe234ec]
location #1 0x818295
/usr/local/bin/postgres postgresql:query__start [sema 0xe234f2]
location #1 0x8183f6
argument #1 8 unsigned bytes @ *(bp - 248)
/usr/local/bin/postgres postgresql:query__done [sema 0xe234f4]
location #1 0x81892e
argument #1 8 unsigned bytes @ *(bp - 248)
/usr/local/bin/postgres postgresql:query__execute__start [sema 0xe234ee]
location #1 0x81dfff
location #2 0x81eba5
/usr/local/bin/postgres postgresql:query__execute__done [sema 0xe234f0]
location #1 0x81e3fa
location #2 0x81ec87
/usr/local/bin/postgres postgresql:sort__start [sema 0xe234f8]
location #1 0x9aae21
argument #1 4 signed bytes @ 0
argument #2 1 signed bytes @ 0
argument #3 4 signed bytes @ *(bp - 44)
argument #4 4 signed bytes @ *(bp + 16)
argument #5 1 signed bytes @ *(bp - 48)
location #2 0x9ab053
argument #1 4 signed bytes @ 3
argument #2 1 signed bytes @ 0
argument #3 4 signed bytes @ ax
argument #4 4 signed bytes @ *(bp - 100)
argument #5 1 signed bytes @ *(bp - 104)
location #3 0x9ab33c
argument #1 4 signed bytes @ 1
argument #2 1 signed bytes @ *(bp - 84)
argument #3 4 signed bytes @ ax
argument #4 4 signed bytes @ *(bp - 88)
argument #5 1 signed bytes @ *(bp - 92)
location #4 0x9ab6d8
argument #1 4 signed bytes @ 2
argument #2 1 signed bytes @ 0
argument #3 4 signed bytes @ 1
argument #4 4 signed bytes @ *(bp - 52)
argument #5 1 signed bytes @ *(bp - 56)
/usr/local/bin/postgres postgresql:sort__done [sema 0xe234fa]
location #1 0x9aba06
argument #1 4 signed bytes @ ax
argument #2 8 signed bytes @ *(bp - 8)
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers