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 1hnsxJ-0005T4-TC for pgsql-admin@arkaria.postgresql.org; Wed, 17 Jul 2019 23:03:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hnsxI-0007UQ-Mg for pgsql-admin@arkaria.postgresql.org; Wed, 17 Jul 2019 23:03:24 +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 1hnsxH-0007DW-AV for pgsql-admin@lists.postgresql.org; Wed, 17 Jul 2019 23:03:24 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1hnsxD-0001kG-CK for pgsql-admin@lists.postgresql.org; Wed, 17 Jul 2019 23:03:22 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 7692321FD7; Wed, 17 Jul 2019 19:03:18 -0400 (EDT) Received: from imap1 ([10.202.2.51]) by compute7.internal (MEProxy); Wed, 17 Jul 2019 19:03:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= quadratum-braccas.com; h=mime-version:message-id:in-reply-to :references:date:from:to:cc:subject:content-type; s=fm2; bh=SCdJ UITjX8RWnWxBrTBjux2YXNulJluOJTCpZdPM9CM=; b=PNW8TgcR48+HlNjTeywn +h7MLG0D3VFQL39hOx6yqsJd8oeIf4fLh8T1oWYqp8w4Yse9YUZcEkwtHZuNJ/Q3 RCGXSWOkGArUDzo9U/Y6K1lNaM3OMVSxWA+QiWY9zsecR3p7wUHSlA1F44O1Hu2m mXIXsD7LP77n7PO7R9pRvi24KAhhNjZKIBfX7tHPdxokGmP3eR/A+aBIeRPaTEwk X1bisRGQMBNYIeTKpevtLZG1kFVuuLa2B6SHMRXCeIf3Ejs7I0stggdbPi0odCoM vJ0vPS7obXEuG3XcQ04ufUQCploxLq9f+76gFoydaVzaLQAKCp3Kp0V+SvpqqKNC qw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=SCdJUI TjX8RWnWxBrTBjux2YXNulJluOJTCpZdPM9CM=; b=B8zYmYkzVDswKhYdwDTpBF nJ4wQEA760Bb5Xu4iWBdRDqvo+/VPZfg5bhj/J95UdijiZqig1LRDK5waNormliF 9Y1Vt1izLWg0GRYKywDTRkGRGeognjit+2R0vpvW02WtJwI+rY4H5cRc357nvFXc crbe2QJroPKqrgtO7sBoNFjXx4ueuQHHCn025vjVwX4mMfaYmntCbaUOQjg4nvYc yTkuMCypHc8BtDUycBZaZiVqlBVA/EsuJhvvudkcQ/XDJA8a9ZqL6ROgQLIUrTjA 7O8TlTcEVF4gAU/+4+oCuaUkwmvRmFHSPrBOLBRozsrrBYr2h5NZlshb/DpXdoTA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrieeggdduiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsegrtderreerredtnecuhfhrohhmpefuuehosgcu oehssghosgesqhhurggurhgrthhumhdqsghrrggttggrshdrtghomheqnecurfgrrhgrmh epmhgrihhlfhhrohhmpehssghosgesqhhurggurhgrthhumhdqsghrrggttggrshdrtgho mhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id EA8FEC200A4; Wed, 17 Jul 2019 19:03:17 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.6-731-g19d3b16-fmstable-20190627v1 Mime-Version: 1.0 Message-Id: <6f57e54e-6b6e-42ed-8605-5bba2a5ea7a0@www.fastmail.com> In-Reply-To: <20190717203204.iteonyhzrtp2alxx@alap3.anarazel.de> References: <2bbb14f7-b894-cf98-986f-59e4711d0aa5@quadratum-braccas.com> <20190717203204.iteonyhzrtp2alxx@alap3.anarazel.de> Date: Wed, 17 Jul 2019 19:03:16 -0400 From: SBob To: "Andres Freund" Cc: pgsql-admin@lists.postgresql.org Subject: Re: xmin value from pg_stat_replication Content-Type: multipart/alternative; boundary=6b17ea47867e4471a17c6790867e1717 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --6b17ea47867e4471a17c6790867e1717 Content-Type: text/plain Thanks for the feedva k, It turns out we were not looking at master & skave. The slave has no replication slot. We are seeing lots of row versions not getting cleaned up, trying toinvestigate all the possible causes. Is there a way to determine which connections (on the master or the slave) are the cause of the row versions not getting cleaned up? Thanks On Wed, Jul 17, 2019, at 4:32 PM, Andres Freund wrote: > Hi, > > On 2019-07-17 12:31:29 -0600, S. Bob wrote: > > We have a master and a standby (Streaming replication). > > > > This query produces a value of approx 1.5million on the master and approx > > 80million on the standby: > > > > > > select slot_name, slot_type, database, xmin from pg_replication_slots order > > by age(xmin); > > I'd suggest using age(xmin) in the output as well, not just in the ORDER > BY, otherwise it's hard to make sense of the value. > > When you say a value of '1.5 million' on the master, how did you > determine that? Because the above doesn't return anything for the > master. The simplest way to determine that is probably: > > SELECT max(age(backend_xmin)) FROM pg_stat_activity; > > > When you say '80 million', do you mean that pg_replication_slots.xmin > was 80 million, or age(pg_replication_slots.xmin)? If it's the former, > then that would indicate that the standby is *not* a problem, but that > you have a long-running transaction or such on the primary. > > Basically, age(xmin) has to be large, not xmin itself. > > > > We are running replication in async mode. > > > > > > A couple of questions: > > > > > > - Is it unusual for the master & standby to differ dramatically like this? > > Do you have very longrunning queries on the standby or primary? That's > typically the reason why xmin is old. > > > > - could the replication slot (i.e. the xmin on the standby) be preventing > > vacuum from cleaning up row versions on the master? > > Yes. > > Greetings, > > Andres Freund > --6b17ea47867e4471a17c6790867e1717 Content-Type: text/html Content-Transfer-Encoding: quoted-printable
Thanks for the = feedva k,

It turns out we were not looking = at master & skave. The slave has no replication slot. We are seeing = lots of row versions not getting cleaned up, trying toinvestigate all th= e possible causes. Is there a way to determine which connections (on the= master or the slave) are the cause of the row versions not getting clea= ned up?

Thanks



On Wed, Jul 17, 2019, at 4:32 PM, Andres = Freund wrote:
Hi,
<= /div>

On 2019-07-17 12:31:29 -0600, S. Bob wrote:
=
> We have a master and a standby (Streaming replication).<= br>
> 
> This query produces a value = of approx 1.5million on the master and approx
> 80milli= on on the standby:
> 
> 
=
> select slot_name, slot_type, database, xmin from pg_repl= ication_slots order
> by age(xmin);

<= /div>
I'd suggest using age(xmin) in the output as well, not just in= the ORDER
BY, otherwise it's hard to make sense of the va= lue.

When you say a value of '1.5 million' = on the master, how did you
determine that? Because the abo= ve doesn't return anything for the
master. The simplest wa= y to determine that is probably:

SELECT max= (age(backend_xmin)) FROM pg_stat_activity;

=
When you say '80 million', do you mean that pg_replicatio= n_slots.xmin
was 80 million, or age(pg_replication_slots.x= min)?  If it's the former,
then that would indicate t= hat the standby is *not* a problem, but that
you have a lo= ng-running transaction or such on the primary.

<= div>Basically, age(xmin) has to be large, not xmin itself.


> We are running replication in async = mode.
> 
> 
&g= t; A couple of questions:
> 
>&nb= sp;
> - Is it unusual for the master & standby to d= iffer dramatically like this?

Do you have v= ery longrunning queries on the standby or primary? That's
= typically the reason why xmin is old.


<= /div>
> - could the replication slot (i.e. the xmin on the standb= y) be preventing
> vacuum from cleaning up row versions= on the master?

Yes.

Greetings,

Andres Freund


--6b17ea47867e4471a17c6790867e1717--