pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: Torsten Förtsch <tfoertsch123@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-general@postgresql.org>
Subject: Re: backend_xmin in pg_stat_replication
Date: Mon, 1 Oct 2018 08:32:11 -0700
Message-ID: <20181001153211.wnsa57kwrfufrd2m@alap3.anarazel.de> (raw)
In-Reply-To: <CAKkG4_nHbvF7K6k1AAwdOQ=3fXbSWNe_n_v7JLTAvn=K_ADRag@mail.gmail.com>
References: <CAKkG4_nHbvF7K6k1AAwdOQ=3fXbSWNe_n_v7JLTAvn=K_ADRag@mail.gmail.com>

Hi,

On 2018-10-01 12:20:26 +0200, Torsten Förtsch wrote:
> if I understand it correctly, backend_xmin in pg_stat_replication is the
> xmin that's reported back by hot_standby_feedback. Given there are no
> long-running transactions on the replica, I presume that value should be
> pretty close to the xmin field of any recent snapshots on the master. This
> is true for all my databases but one:
> 
> select application_name,
>        txid_snapshot_xmin(txid_current_snapshot()),
>        backend_xmin::TEXT::BIGINT,
> 
>  txid_snapshot_xmin(txid_current_snapshot())-backend_xmin::TEXT::BIGINT
>   from pg_stat_replication;
> 
>  application_name | txid_snapshot_xmin | backend_xmin |  ?column?
> ------------------+--------------------+--------------+------------
>  xxxxxxxxxx       |         6 957 042 833 |   2 662 075 435 | 4 294 967 398

I don't think the calculation you're doing here is correct.
backend_xmin is an xid (max 2^32-1), whereas txid_snapshot_xmin returns
an xid *with* epoch (max 2^64-1). What you're measuring here is simply
the fact that the xid counter has wrapped around.

Greetings,

Andres Freund




view thread (3+ messages)  latest in thread

Message-ID: <20181001153211.wnsa57kwrfufrd2m@alap3.anarazel.de>
Permalink:  ../20181001153211.wnsa57kwrfufrd2m@alap3.anarazel.de/
Also on:    postgresql.org/message-id/20181001153211.wnsa57kwrfufrd2m@alap3.anarazel.de

 · 

reply

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-general@postgresql.org
  Cc: andres@anarazel.de, tfoertsch123@gmail.com
  Subject: Re: backend_xmin in pg_stat_replication
  In-Reply-To: <20181001153211.wnsa57kwrfufrd2m@alap3.anarazel.de>
  References: <CAKkG4_nHbvF7K6k1AAwdOQ=3fXbSWNe_n_v7JLTAvn=K_ADRag@mail.gmail.com> <20181001153211.wnsa57kwrfufrd2m@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