pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add tests for lock statistics, take two
Date: Sun, 05 Apr 2026 23:52:37 +0000
Message-ID: <E1w9XGe-0039Kk-2I@gemulon.postgresql.org> (raw)

Add tests for lock statistics, take two

Commit 7c64d56fd976 has removed the isolation test providing coverage
for lock statistics due to some instability in the CI, where the
deadlock timeout may not have enough time to process, preventing the
stats data to be updated.  These also relied on a set of hardcoded
sleeps.

This commit switches the test suite to TAP, instead, that uses an
injection point with a wait to avoid the sleeps.  The injection point is
added in ProcSleep(), once we know that the deadlock timeout has fired
and that the stats have been updated.

Multiple lock patterns are checked, all rely on the same workflow, with
two sessions:
- session 1 holds a given lock type.
- session 2 attaches to the new injection point with the wait action.
- session 2 attempts to acquire a lock conflicting with the lock of
session 1, waiting for the injection point to be reached.
- session 1 releases its lock, session 2 commits.
- pg_stat_lock is polled until the counters are updated for the lock
type.

Bertrand's version of the patch introduced a new routine to
BackgroundPsql() to detect the blocked background sessions.  I have
tweaked the test so as we use the same method as some of the other tests
instead, based on some \echo commands.  This test has been run multiple
times in the CI, all passing, so I'd like to think that this is more
stable than the first version attempted.

Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Co-authored-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/acNTR1lLHwQJ0o+P@ip-10-97-1-34.eu-west-3.compute.internal

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/557a9f1e3e62894cc3302eda72d9df091d72f37b

Modified Files
--------------
src/backend/storage/lmgr/proc.c                |   2 +
src/test/modules/test_misc/meson.build         |   1 +
src/test/modules/test_misc/t/011_lock_stats.pl | 251 +++++++++++++++++++++++++
3 files changed, 254 insertions(+)



Message-ID: <E1w9XGe-0039Kk-2I@gemulon.postgresql.org>
Permalink:  ../E1w9XGe-0039Kk-2I@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1w9XGe-0039Kk-2I@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Add tests for lock statistics, take two
  In-Reply-To: <E1w9XGe-0039Kk-2I@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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