On Tue, Jun 10, 2025 at 5:46 PM Dominique Devienne <ddevie...@gmail.com> wrote: > On Tue, Jun 10, 2025 at 4:27 PM Tom Lane <t...@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