]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
pg_stat_activity: show NULL stmt start time for walsenders
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 7 Jan 2020 20:38:48 +0000 (17:38 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 7 Jan 2020 20:38:48 +0000 (17:38 -0300)
Returning a non-NULL time is pointless, sinc a walsender is not a
process that would be running normal transactions anyway, but the code
was unintentionally exposing the process start time intermittently,
which was not only bogus but it also confused monitoring systems looking
for idle transactions.  Fix by avoiding all updates in walsenders.

Backpatch to 11, where walsenders started appearing in pg_stat_activity.

Reported-by: Tomas Vondra
Discussion: https://postgr.es/m/20191209234409.exe7osmyalwkt5j4@development

src/backend/access/transam/xact.c

index 7c1771eae762517aeb1e739d4cd554767a754b34..7b4d4b75f1b296ce14deaf08b54dc7c57260a60a 100644 (file)
@@ -750,6 +750,13 @@ GetCurrentTransactionStopTimestamp(void)
 void
 SetCurrentStatementStartTimestamp(void)
 {
+       /*
+        * Skip if on a walsender; this is not needed, and it confuses monitoring
+        * if we publish non-NULL values.
+        */
+       if (am_walsender)
+               return;
+
        if (!IsParallelWorker())
                stmtStartTimestamp = GetCurrentTimestamp();
        else