From: Alvaro Herrera Date: Tue, 7 Jan 2020 20:38:48 +0000 (-0300) Subject: pg_stat_activity: show NULL stmt start time for walsenders X-Git-Tag: REL_10_12~44 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8de3b68faffcb5898244bd8af3abfb6edb11543f;p=thirdparty%2Fpostgresql.git pg_stat_activity: show NULL stmt start time for walsenders 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 pg10: previously I misidentified the branches that show auxiliary processes in pg_stat_activity. Reported-by: Tomas Vondra Discussion: https://postgr.es/m/20191209234409.exe7osmyalwkt5j4@development --- diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 9b252213d95..0dd6b82f99a 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -758,6 +758,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