Skip to content

Instantly share code, notes, and snippets.

@cabecada
Created April 29, 2024 10:57
Show Gist options
  • Save cabecada/84b4af11372fd31a9b5951ac14de69dc to your computer and use it in GitHub Desktop.
Save cabecada/84b4af11372fd31a9b5951ac14de69dc to your computer and use it in GitHub Desktop.
./configure --prefix /opt/17/usr/local --enable-tap-tests --with-perl --with-python --with-openssl --enable-dtrace --enable-debug --enable-cassert CFLAGS="-ggdb -Og -g3 -fno-omit-frame-pointer -DLOCK_DEBUG -DBTREE_BUILD_STATS -DWAL_DEBUG"
make
make install
export PATH=/opt/17/usr/local/bin:$PATH
select name,setting from pg_settings where name ~ 'trace.*locks';
name | setting
-----------------+---------
trace_locks | on
trace_lwlocks | on
trace_userlocks | on
(3 rows)
postgres=# show trace_lock_table;
trace_lock_table
------------------
0
(1 row)
postgres=# create table t(col1 int primary key);
CREATE TABLE
postgres=# select 't'::regclass::oid;
oid
-------
16398
(1 row)
postgres=# set trace_lock_table = 16398;
SET
postgres=# alter table t add column col4 bigint;
ALTER TABLE
---then in logs
2024-04-29 16:25:33.608 IST [11801] LOG: LockAcquire: new: lock(0x7f3d498989d0) id(5,16419,0,0,0,1) grantMask(0) req(0,0,0,
0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0 wait(0) type(AccessExclusiveLock)
2024-04-29 16:25:33.608 IST [11801] STATEMENT: alter table t add column col4 bigint;
2024-04-29 16:25:33.608 IST [11801] LOG: LockAcquire: new: proclock(0x7f3d49949e30) lock(0x7f3d498989d0) method(1) proc(0x7f3d49c49590) hold(0)
2024-04-29 16:25:33.608 IST [11801] STATEMENT: alter table t add column col4 bigint;
2024-04-29 16:25:33.608 IST [11801] LOG: LockCheckConflicts: no conflict: proclock(0x7f3d49949e30) lock(0x7f3d498989d0) method(1) proc(0x7f3d49c49590) hold(0)
2024-04-29 16:25:33.608 IST [11801] STATEMENT: alter table t add column col4 bigint;
2024-04-29 16:25:33.608 IST [11801] LOG: GrantLock: lock(0x7f3d498989d0) id(5,16419,0,0,0,1) grantMask(100) req(0,0,0,0,0,0,0)=1 grant(0,0,0,0,0,0,0)=1 wait(0) type(AccessExclusiveLock)
2024-04-29 16:25:33.608 IST [11801] STATEMENT: alter table t add column col4 bigint;
2024-04-29 16:25:33.608 IST [11801] LOG: 11801: LWLockRelease(LockManager 0x7f3d41084c00): excl 1 shared 0 haswaiters 0 waiters 0 rOK 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment