]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Reimplement nullification of walsender timestamp
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 8 Jan 2020 17:33:49 +0000 (14:33 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 8 Jan 2020 17:33:49 +0000 (14:33 -0300)
Make the value null only at pg_stat_activity-output time, as suggested
by Tom Lane, instead of messing with the internal state.  This should
appease buildfarm members with force_parallel_mode=regress, which are
running parallel queries on logical replication walsenders.

The fact that walsenders can run parallel queries should perhaps be
studied more carefully, but for the moment let's get rid of the red
blots in buildfarm.

Backpatch to pg10, like the previous commit.

Discussion: https://postgr.es/m/30804.1578438763@sss.pgh.pa.us

src/backend/access/transam/xact.c
src/backend/utils/adt/pgstatfuncs.c

index 7b4d4b75f1b296ce14deaf08b54dc7c57260a60a..7c1771eae762517aeb1e739d4cd554767a754b34 100644 (file)
@@ -750,13 +750,6 @@ 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
index e95e3471846b999836065be368f23059d25d1b2c..02ab6433f9468e1346c54804c1a8be28d6fe9a41 100644 (file)
@@ -736,7 +736,13 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
                        else
                                nulls[7] = true;
 
-                       if (beentry->st_xact_start_timestamp != 0)
+                       /*
+                        * Don't expose transaction time for walsenders; it confuses
+                        * monitoring, particularly because we don't keep the time up-to-
+                        * date.
+                        */
+                       if (beentry->st_xact_start_timestamp != 0 &&
+                               beentry->st_backendType != B_WAL_SENDER)
                                values[8] = TimestampTzGetDatum(beentry->st_xact_start_timestamp);
                        else
                                nulls[8] = true;