Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uPHj8-0047dm-T5 for pgsql-general@arkaria.postgresql.org; Wed, 11 Jun 2025 09:26:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uPHj5-001XXI-QG for pgsql-general@arkaria.postgresql.org; Wed, 11 Jun 2025 09:26:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uPHj5-001XXA-DF for pgsql-general@lists.postgresql.org; Wed, 11 Jun 2025 09:26:32 +0000 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uPHj4-001PEB-0y for pgsql-general@lists.postgresql.org; Wed, 11 Jun 2025 09:26:31 +0000 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-2e541e0b974so4441268fac.1 for ; Wed, 11 Jun 2025 02:26:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749633989; x=1750238789; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=op8qCWuNbjVWsxb48Xrwm9d9gWTsJICQQzeSox86rII=; b=lp2XDXq5bH7i2zaROU022zVWktyWkrf3prLhhu4jxj8NoVd9gmdMzLWtSPp+gHzKL8 ctMLYxAcKoxNj1r8qArniaplbGcwIpgoS0XdZaDp5WFcyHBajiWzkY8s/xn7Rx5akLN/ +nCxkJeS/Q+MoLUjod0Wbvqk9V/4v3qaS7Q3+mJ6X+6jzEw9KKRLRiCbyIXnipu1tJ8l F/n4y8o6g05i/TKdWRiN8299BNf5vvWTuMeVolSoPSfNVg6kJoibXC1aJPf6C3Hx0R5p +7b3LYJm2Ks57d4vEhSb6fqVmvYL2dkh1504IH2vmAcOmDalG0JeGRdK61QO3A7Ad2hd UuWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749633989; x=1750238789; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=op8qCWuNbjVWsxb48Xrwm9d9gWTsJICQQzeSox86rII=; b=fHgh/SE3WX99yXNmumaL3+ZXar4q8iZmCrk7/PktEJK1QOtJ0d/LCltxqi6sNUW+o6 L8mMpJV13c53ZfS5X/eCcxJTp6MTBYE8NOx32S45NmFV/l32tpYDqxY4VEl3i2WdmnWm HyClAge6rOVQGm1f0UFZzxHoQvWbhOWUUY1dRM2k+MRGE6BluIpGHVi522gCAVPA0TPf KiKQjbJ21/351JcA9TiM5J4DZJSR5Ben/G7LNAb6MG6ZxZKuXIoxpu+E0vRaZ48WJKai xU46cfeznfDJD1U12tUBHvmqh5+c0Q0/4wDALJ+tIVDHQxIwlu4LGrVIU2NAwVKj73N1 YMwg== X-Gm-Message-State: AOJu0YwLcezuVa7MAD14REUk6QetWoRkAjDAvgUTlLLCn3/4LoOM7ePN K3Df3/VYNewu4+aR4vBiYuQBEQF0tfJih32f/4QNLFOr15U3X39jpZSWW+QwoseKdyc8Yknf3WW xz2n6ZLNq5u7NBK7SWmtx4a0ON2SVJI1C6upM X-Gm-Gg: ASbGnct+9DyVg/naSgzst4TgB10iWs8TLsEsBg7jVB8MdVRLpOxZznaloRSxtUk2sj0 3h/TMd/zuEtRjVT6Wxp7D+88fdRfaiaJHnpcLOVkd2CBt5NS/qqJ8zQ6DSY37VeMejvJ7zFJqf4 YR6o7BCvA6jjg+nvmehdK/eUmhSvh/6D6pYpguskHP/qDvAQ== X-Google-Smtp-Source: AGHT+IFLVM+Zu8do6WyO7l4RDfssmfZEyBb2ADAt7Fs9dIbjTwZlweumZnnYlYij45CuPS8aTeIaBlLPyZa5NZVcZaI= X-Received: by 2002:a05:6870:ae07:b0:2ea:87d7:5a35 with SMTP id 586e51a60fabf-2ea96e8ba0dmr1545074fac.36.1749633989213; Wed, 11 Jun 2025 02:26:29 -0700 (PDT) MIME-Version: 1.0 References: <755975.1749565677@sss.pgh.pa.us> In-Reply-To: From: Dominique Devienne Date: Wed, 11 Jun 2025 11:26:18 +0200 X-Gm-Features: AX0GCFusYBEs0XY7pfytxoMx-1oMBqPSQh20hM6waIfhjYELmpZYVQNGXcE6oF8 Message-ID: Subject: Re: is pg_stat_activity "transactional"? How fast does it update? To: Tom Lane Cc: pgsql-general@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Jun 10, 2025 at 5:46=E2=80=AFPM Dominique Devienne wrote: > On Tue, Jun 10, 2025 at 4:27=E2=80=AFPM Tom Lane wrot= e: > > 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