Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ioyeS-0002XG-S6 for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Jan 2020 23:52:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ioyeR-0002G4-G3 for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Jan 2020 23:52:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ioyeR-0002Fx-3N for pgsql-hackers@lists.postgresql.org; Tue, 07 Jan 2020 23:52:43 +0000 Received: from mail-qk1-x742.google.com ([2607:f8b0:4864:20::742]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ioyeO-0005eY-Pm for pgsql-hackers@postgresql.org; Tue, 07 Jan 2020 23:52:41 +0000 Received: by mail-qk1-x742.google.com with SMTP id x129so1085637qke.8 for ; Tue, 07 Jan 2020 15:52:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=O7LnVfjDmhR/YIv81EEKcLCnIh+DK3POAq5RYs58E+k=; b=JsllCJCsxI1TmAUkm3fZwJy3ZiCvZeEGr8geI5TALptlN/wKrAb2CikjHkdIMTFS+0 sMr1Gxv9Bispc5XEpkZF2WYiPnWDQKIBqFU1kgMIMMEE1OicHHl8dfNImlz9ZfhKONyM i7bW5FoPj3u3lNSsGL47dnoUW2xjFHWPJj5pWtAos57nmxR9iALbZDWroaZKsCWcrZrn 4vJr/z3sN8YnnvmvKRi7O33gqRLjk2r9oi6dVZNLgQg9xYb4k6KIFUCE5CBbAg3saO4C B4n/ZYRQbwpDOQ/IzZlZUNpOhRV+nY+OXxyA409RRyeQwxdJlnH3MUl0wZKqiGulAfUO IQoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=O7LnVfjDmhR/YIv81EEKcLCnIh+DK3POAq5RYs58E+k=; b=k3RGeurQ9OIMZ68H1NTOsnaBfDwAHSiFVxWRxHeooD9zybkwhc4oimD69yPF5/bwiW 2Y5lQHyT4IsCPKdEEddI3tD7j7IPky+IT0gr4ujGMBD8b9/Tzerb3/qn5EZ2uc3A5ms7 FMyFSQ+NWa7M/o9t+rL+vqA1dslq4JS2ptNtVfjMDnChIf+7CJuTMLjB0rq42Q4a7f5X VAOzlsOgNNBF6kRMufbMr+k3EYeztz+SBJGQ+uh5cAlZDlRCidkZGpei/i2InkXZ5I/n YFwTF3xoJFslP3M/SNcOM0H9y1TIGB0dHjLRAN2UqDY9pL62rkD2K5ai688MyL1FBUEi okjw== X-Gm-Message-State: APjAAAVT67jrmM9rVdoNmRG+S7j/fJaQDi3Cnsu7n96qvSV0Q17H5Kvx DGkqCmCG1oeFl8jApNekFoYDmA== X-Google-Smtp-Source: APXvYqx9Q2GqkZBXHIvBMbe7QZ8EqUKdIHnYkwb/UVhe5V5eJ/zbFv24U/eccKnlcwNd8yFXV9R+ag== X-Received: by 2002:a05:620a:1307:: with SMTP id o7mr1849395qkj.312.1578441159582; Tue, 07 Jan 2020 15:52:39 -0800 (PST) Received: from nimloth.alvh.no-ip.org ([191.126.227.209]) by smtp.gmail.com with ESMTPSA id 4sm573950qkv.44.2020.01.07.15.52.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 15:52:38 -0800 (PST) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 42C06301DEF; Tue, 7 Jan 2020 20:52:34 -0300 (-03) Date: Tue, 7 Jan 2020 20:52:34 -0300 From: Alvaro Herrera To: Tom Lane Cc: Tomas Vondra , Kyotaro Horiguchi , craig@2ndquadrant.com, pgsql-hackers@postgresql.org Subject: Re: xact_start for walsender & logical decoding not updated Message-ID: <20200107235234.GA21729@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Qxx1br4bt0+wmkIi" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <30804.1578438763@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Qxx1br4bt0+wmkIi Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2020-Jan-07, Tom Lane wrote: > I wrote: > > The buildfarm seems less than happy with this. > > ... and, having now looked at the patch, I'm not surprised. > Breaking stmtStartTimestamp, which is what you did, seems like > an awfully side-effect-filled route to the goal. If you want > to prevent monitoring from showing this, why didn't you just > prevent monitoring from showing it? That is, I'd have expected > some am_walsender logic in or near pgstat.c, not here. That seems a pretty simple patch; attached (untested). However, my patch seemed a pretty decent way to achieve the goal, and I don't understand why it causes the failure, or indeed why we care about stmtStartTimestamp at all. I'll look into this again tomorrow. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --Qxx1br4bt0+wmkIi Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="walsender-ts.patch" commit 2808f98edb6889ec602534e070e6a2c660f6377e Author: Alvaro Herrera AuthorDate: Tue Jan 7 20:33:28 2020 -0300 CommitDate: Tue Jan 7 20:33:28 2020 -0300 fix previous diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 0dd6b82f99..9b252213d9 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -758,13 +758,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 diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index 20ce48b2d8..8557684aad 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -732,7 +732,8 @@ pg_stat_get_activity(PG_FUNCTION_ARGS) else nulls[7] = true; - if (beentry->st_xact_start_timestamp != 0) + 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; --Qxx1br4bt0+wmkIi--