Re: is pg_stat_activity "transactional"? How fast does it update?

From: Dominique Devienne <ddevienne(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: is pg_stat_activity "transactional"? How fast does it update?
Date: 2025-06-11 09:26:18
Message-ID: CAFCRh-8twaDLV2uEy=R8e7U29LOAPhRN8vVzq712UE_J=7Ld4w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Jun 10, 2025 at 5:46 PM Dominique Devienne <ddevienne(at)gmail(dot)com> wrote:
> On Tue, Jun 10, 2025 at 4:27 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Max Madden 2025-06-11 10:57:51 Re: Logical Replication Memory Allocation Error - "invalid memory alloc request size"
Previous Message Hayato Kuroda (Fujitsu) 2025-06-11 02:31:44 RE: Logical Replication Memory Allocation Error - "invalid memory alloc request size"