Re: is pg_stat_activity "transactional"? How fast does it update? - Mailing list pgsql-general

From Dominique Devienne
Subject Re: is pg_stat_activity "transactional"? How fast does it update?
Date
Msg-id CAFCRh-8twaDLV2uEy=R8e7U29LOAPhRN8vVzq712UE_J=7Ld4w@mail.gmail.com
Whole thread Raw
In response to Re: is pg_stat_activity "transactional"? How fast does it update?  (Dominique Devienne <ddevienne@gmail.com>)
List pgsql-general
On Tue, Jun 10, 2025 at 5:46 PM Dominique Devienne <ddevienne@gmail.com> wrote:
> On Tue, Jun 10, 2025 at 4:27 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > PQfinish is asynchronous: [...]
> > [...] pg_stat_activity() takes a snapshot of the view's contents
> Many thanks Tom. Didn't know either of those facts.

Hi. I ended up polling pg_stat_activity to wait for the disappearance
of the backend, to avoid the race in my unit tests. Initially
pg_stat_clear_snapshot() seemed to help, but then it didn't. Not
ideal, but I don't see any solution (work-around, really). There's a
new LOGIN event trigger, but no symmetrical FINISH one, and those are
restricted to privileged users, so useless in my case. Oh well. --DD



pgsql-general by date:

Previous
From: "Hayato Kuroda (Fujitsu)"
Date:
Subject: RE: Logical Replication Memory Allocation Error - "invalid memory alloc request size"
Next
From: Max Madden
Date:
Subject: Re: Logical Replication Memory Allocation Error - "invalid memory alloc request size"