aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2020-01-07 17:38:48 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2020-01-07 17:38:48 -0300
commit896db774e5b0a851792f02c8a19ea9b07c9dcc23 (patch)
tree7f3295d3f58d98d2f2e4ee95c7c698d2c8ba322b
parent7474393e0b98971c7779cbb23c2d7d17e38a944c (diff)
downloadpostgresql-896db774e5b0a851792f02c8a19ea9b07c9dcc23.tar.gz
postgresql-896db774e5b0a851792f02c8a19ea9b07c9dcc23.zip
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
-rw-r--r--src/backend/access/transam/xact.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index 7c1771eae76..7b4d4b75f1b 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -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