postgres.git / summary / log / commit / refs

commit    b175bd59fa54a90d21bc541f812643ac45281b98
Author:   Alvaro Herrera <alvherre@alvh.no-ip.org>
Date:     Tue Jan 07 20:38:48 2020 +0000
First released in: 13.0, 10.12, 11.7, 12.2

    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 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 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 017f03b6d8c..cbc35454a7e 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -816,6 +816,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 [parent: ce242ae154dd]