From: Andres Freund <andres@anarazel.de>
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: pgsql-hackers@postgresql.org
Subject: Re: xact_start for walsender & logical decoding not updated
Date: Mon, 9 Dec 2019 16:04:40 -0800
Message-ID: <20191210000440.daqpb6nvk3dpcblr@alap3.anarazel.de> (raw)
In-Reply-To: <20191209234409.exe7osmyalwkt5j4@development>
References: <20191209234409.exe7osmyalwkt5j4@development>
Hi,
On 2019-12-10 00:44:09 +0100, Tomas Vondra wrote:
> I think there's a minor bug in pg_stat_activity tracking of walsender
> processes. The issue is that xact_start is only updated at the very
> beginning when the walsender starts (so it's almost exactly equal to
> backend_start) and then just flips between NULL and that value.
>
> Reproducing this is trivial - just create a publication/subscription
> with the built-in logical replication, and run arbitrary workload.
> You'll see that the xact_start value never changes.
>
> I think the right fix is calling SetCurrentStatementStartTimestamp()
> right before StartTransactionCommand() in ReorderBufferCommit, per the
> attached patch.
> --
> Tomas Vondra http://www.2ndQuadrant.com
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
> diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
> index 53affeb877..5235fb31b8 100644
> --- a/src/backend/replication/logical/reorderbuffer.c
> +++ b/src/backend/replication/logical/reorderbuffer.c
> @@ -1554,7 +1554,10 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid,
> if (using_subtxn)
> BeginInternalSubTransaction("replay");
> else
> + {
> + SetCurrentStatementStartTimestamp();
> StartTransactionCommand();
> + }
I'm quite doubtful this is useful. To me this seems to do nothing but
add the overhead of timestamp computation - which isn't always that
cheap. I don't think you really can draw meaning from this?
Greetings,
Andres Freund
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: andres@anarazel.de, tomas.vondra@2ndquadrant.com
Subject: Re: xact_start for walsender & logical decoding not updated
In-Reply-To: <20191210000440.daqpb6nvk3dpcblr@alap3.anarazel.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox