Re: adding wait_start column to pg_locks
torikoshia <torikoshia@oss.nttdata.com>
From: torikoshia <torikoshia@oss.nttdata.com>
To: Fujii Masao <masao.fujii@oss.nttdata.com>
Cc: Ian Lawrence Barwick <barwick@gmail.com>, Robert Haas
<robertmhaas@gmail.com>, Justin Pryzby <pryzby@telsasoft.com>, pgsql-hackers
<pgsql-hackers@postgresql.org>
Date: 2021-02-04T15:03:51Z
Lists: pgsql-hackers
Attachments
- v7-0001-To-examine-the-duration-of-locks-we-did-join-on-p.patch (text/x-diff) patch v7-0001
On 2021-02-03 11:23, Fujii Masao wrote: >> 64-bit fetches are not atomic on some platforms. So spinlock is >> necessary when updating "waitStart" without holding the partition >> lock? Also GetLockStatusData() needs spinlock when reading >> "waitStart"? > > Also it might be worth thinking to use 64-bit atomic operations like > pg_atomic_read_u64(), for that. Thanks for your suggestion and advice! In the attached patch I used pg_atomic_read_u64() and pg_atomic_write_u64(). waitStart is TimestampTz i.e., int64, but it seems pg_atomic_read_xxx and pg_atomic_write_xxx only supports unsigned int, so I cast the type. I may be using these functions not correctly, so if something is wrong, I would appreciate any comments. About the documentation, since your suggestion seems better than v6, I used it as is. Regards, -- Atsushi Torikoshi
Commits
-
Initialize atomic variable waitStart in PGPROC, at postmaster startup.
- f05ed5a5cfa5 14.0 landed
-
Display the time when the process started waiting for the lock, in pg_locks, take 2
- 46d6e5f56790 14.0 landed
-
Display the time when the process started waiting for the lock, in pg_locks.
- 3b733fcd0419 14.0 landed