pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Display the time when the process started waiting for the lock,
2+ messages / 1 participants
[nested] [flat]

* pgsql: Display the time when the process started waiting for the lock,
@ 2021-02-09 09:12  Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Fujii Masao @ 2021-02-09 09:12 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Display the time when the process started waiting for the lock, in pg_locks.

This commit adds new column "waitstart" into pg_locks view. This column
reports the time when the server process started waiting for the lock
if the lock is not held. This information is useful, for example, when
examining the amount of time to wait on a lock by subtracting
"waitstart" in pg_locks from the current time, and identify the lock
that the processes are waiting for very long.

This feature uses the current time obtained for the deadlock timeout
timer as "waitstart" (i.e., the time when this process started waiting
for the lock). Since getting the current time newly can cause overhead,
we reuse the already-obtained time to avoid that overhead.

Note that "waitstart" is updated without holding the lock table's
partition lock, to avoid the overhead by additional lock acquisition.
This can cause "waitstart" in pg_locks to become NULL for a very short
period of time after the wait started even though "granted" is false.
This is OK in practice because we can assume that users are likely to
look at "waitstart" when waiting for the lock for a long time.

Bump catalog version.

Author: Atsushi Torikoshi
Reviewed-by: Ian Lawrence Barwick, Robert Haas, Justin Pryzby, Fujii Masao
Discussion: https://postgr.es/m/a96013dc51cdc56b2a2b84fa8a16a993@oss.nttdata.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3b733fcd04195399db56f73f0616b4f5c6828e18

Modified Files
--------------
contrib/amcheck/expected/check_btree.out |  4 ++--
doc/src/sgml/catalogs.sgml               | 13 +++++++++++++
src/backend/storage/ipc/standby.c        | 24 +++++++++++++++++++++++-
src/backend/storage/lmgr/lock.c          |  8 ++++++++
src/backend/storage/lmgr/proc.c          | 19 +++++++++++++++++++
src/backend/utils/adt/lockfuncs.c        |  9 ++++++++-
src/include/catalog/catversion.h         |  2 +-
src/include/catalog/pg_proc.dat          |  6 +++---
src/include/storage/lock.h               |  3 +++
src/include/storage/proc.h               |  2 ++
src/test/regress/expected/rules.out      |  5 +++--
11 files changed, 85 insertions(+), 10 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Display the time when the process started waiting for the lock,
@ 2021-02-15 06:15  Fujii Masao <fujii@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Fujii Masao @ 2021-02-15 06:15 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Display the time when the process started waiting for the lock, in pg_locks, take 2

This commit adds new column "waitstart" into pg_locks view. This column
reports the time when the server process started waiting for the lock
if the lock is not held. This information is useful, for example, when
examining the amount of time to wait on a lock by subtracting
"waitstart" in pg_locks from the current time, and identify the lock
that the processes are waiting for very long.

This feature uses the current time obtained for the deadlock timeout
timer as "waitstart" (i.e., the time when this process started waiting
for the lock). Since getting the current time newly can cause overhead,
we reuse the already-obtained time to avoid that overhead.

Note that "waitstart" is updated without holding the lock table's
partition lock, to avoid the overhead by additional lock acquisition.
This can cause "waitstart" in pg_locks to become NULL for a very short
period of time after the wait started even though "granted" is false.
This is OK in practice because we can assume that users are likely to
look at "waitstart" when waiting for the lock for a long time.

The first attempt of this patch (commit 3b733fcd04) caused the buildfarm
member "rorqual" (built with --disable-atomics --disable-spinlocks) to report
the failure of the regression test. It was reverted by commit 890d2182a2.
The cause of this failure was that the atomic variable for "waitstart"
in the dummy process entry created at the end of prepare transaction was
not initialized. This second attempt fixes that issue.

Bump catalog version.

Author: Atsushi Torikoshi
Reviewed-by: Ian Lawrence Barwick, Robert Haas, Justin Pryzby, Fujii Masao
Discussion: https://postgr.es/m/a96013dc51cdc56b2a2b84fa8a16a993@oss.nttdata.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/46d6e5f567906389c31c4fb3a2653da1885c18ee

Modified Files
--------------
contrib/amcheck/expected/check_btree.out |  4 ++--
doc/src/sgml/catalogs.sgml               | 13 +++++++++++++
src/backend/access/transam/twophase.c    |  9 ++++++++-
src/backend/storage/ipc/standby.c        | 24 +++++++++++++++++++++++-
src/backend/storage/lmgr/lock.c          |  8 ++++++++
src/backend/storage/lmgr/proc.c          | 20 ++++++++++++++++++++
src/backend/utils/adt/lockfuncs.c        |  9 ++++++++-
src/include/catalog/catversion.h         |  2 +-
src/include/catalog/pg_proc.dat          |  6 +++---
src/include/storage/lock.h               |  3 +++
src/include/storage/proc.h               |  2 ++
src/test/regress/expected/rules.out      |  5 +++--
12 files changed, 94 insertions(+), 11 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2021-02-15 06:15 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-02-09 09:12 pgsql: Display the time when the process started waiting for the lock, Fujii Masao <fujii@postgresql.org>
2021-02-15 06:15 pgsql: Display the time when the process started waiting for the lock, Fujii Masao <fujii@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox