public inbox for [email protected]  
help / color / mirror / Atom feed
From: Benoit Lobréau <[email protected]>
To: Tom Lane <[email protected]>
To: [email protected]
Cc: 'Rajesh Kumar' <[email protected]>
Cc: [email protected]
Subject: Re: Commit with wait event on advisory lock!
Date: Tue, 4 Feb 2025 16:22:45 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<CAJk5AtY-TWUYU7TR3KfbOyzvfDytTFTJfVyB1cKWpwKxNSV3Ww@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>

On 1/22/25 11:17 PM, Tom Lane wrote:
>> By the way I also have commits which are waiting on ClientRead...
> 
> That, on the other hand, is surely impossible.  I think maybe you
> are misreading the stats display.  Typically I'd expect that such a
> case indicates that the session is idle (awaiting a new command)
> and the COMMIT is the last thing it did before that.
> 
> 			regards, tom lane

I can reproduce the issue using pgbench spamming "BEGIN; COMMIT;" and
and running this query in psql:

SELECT DISTINCT state, wait_event, query
FROM pg_stat_activity
WHERE backend_type ILIKE '%client%'
AND query ILIKE 'COMMIT%'
\watch 0.5

After a short while I get the following :

active | ClientRead | COMMIT;

I looked into src/backend/utils/adt/pgstatfuncs.c and found that
the state comes from the PgBackendStatus array, while the wait
events are fetched from the proc array (using st_procpid taken
from the backend status).

I don't think there is a guarantee that this "snapshot" is
consistent across both arrays. It might just be a case of spamming
pg_stat_activity and occasionally ending up with an "inconsistent
snapshot."

Do you think this explanation holds weight?

I haven't been able to reproduce the advisory lock issue yet.

-- 
Benoit Lobréau
Consultant
http://dalibo.com






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: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Commit with wait event on advisory lock!
  In-Reply-To: <[email protected]>

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

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