From: Andres Freund <andres@anarazel.de>
To: S. Bob <sbob@quadratum-braccas.com>
Cc: pgsql-admin@lists.postgresql.org
Subject: Re: xmin value from pg_stat_replication
Date: Wed, 17 Jul 2019 13:32:04 -0700
Message-ID: <20190717203204.iteonyhzrtp2alxx@alap3.anarazel.de> (raw)
In-Reply-To: <2bbb14f7-b894-cf98-986f-59e4711d0aa5@quadratum-braccas.com>
References: <2bbb14f7-b894-cf98-986f-59e4711d0aa5@quadratum-braccas.com>
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
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: andres@anarazel.de, sbob@quadratum-braccas.com
Subject: Re: xmin value from pg_stat_replication
In-Reply-To: <20190717203204.iteonyhzrtp2alxx@alap3.anarazel.de>
References: <2bbb14f7-b894-cf98-986f-59e4711d0aa5@quadratum-braccas.com> <20190717203204.iteonyhzrtp2alxx@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