aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xact.c
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
commitfce9ba8192b48d7b4a57a19d92044c4f378a41a0 (patch)
tree3dd4760f1e58e5479e45b7cc7bb4f3d6343a5f1a /src/backend/access/transam/xact.c
parentb89845267a6b0197e86b5a189d26f90f6a45c05f (diff)
downloadpostgresql-fce9ba8192b48d7b4a57a19d92044c4f378a41a0.tar.gz
postgresql-fce9ba8192b48d7b4a57a19d92044c4f378a41a0.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
Diffstat (limited to 'src/backend/access/transam/xact.c')
-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 bd396f0f08f..075b2431833 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -817,6 +817,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