pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jehan-Guillaume de Rorthais <jgdr@dalibo.com>
To: Paolo Saudin <paolosaudin@gmail.com>
Cc: PostgreSQL <pgsql-general@postgresql.org>
Subject: Re: Replication sequence
Date: Tue, 16 Feb 2021 10:51:45 +0100
Message-ID: <20210216105145.03b5943b@firost> (raw)
In-Reply-To: <CADtZQgnz9AvzigpeSBAyT53TrZRF42DqZVN7SscpN2DMkJDTYQ@mail.gmail.com>
References: <CADtZQgnz9AvzigpeSBAyT53TrZRF42DqZVN7SscpN2DMkJDTYQ@mail.gmail.com>

On Mon, 15 Feb 2021 18:55:14 +0100
Paolo Saudin <paolosaudin@gmail.com> wrote:

> Hi all,
> I have two servers, a primary and a secondary one with a streaming replica
> setup.
> Today I noticed that some sequences are not lined-up, the replica ones are
> well ahead, while the records number is the same. How is it possible?

This is because sequences are not WAL logged on every nextval() call, but by
batch of sequence cache+32 values. As standbys are fed with WAL stream from
primary, their sequences appears jump, then stall, then jump, etc.

See:
  https://git.postgresql.org/cgit/postgresql.git/tree/src/backend/commands/sequence.c?id=f672df5fdd22d...

  https://git.postgresql.org/cgit/postgresql.git/tree/src/backend/commands/sequence.c?id=f672df5fdd22d...

I'm not sure if this is documented somewhere... ?





view thread (7+ messages)  latest in thread

Message-ID: <20210216105145.03b5943b@firost>
Permalink:  ../20210216105145.03b5943b@firost/
Also on:    postgresql.org/message-id/20210216105145.03b5943b@firost

 · 

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: jgdr@dalibo.com, paolosaudin@gmail.com
  Subject: Re: Replication sequence
  In-Reply-To: <20210216105145.03b5943b@firost>
  References: <CADtZQgnz9AvzigpeSBAyT53TrZRF42DqZVN7SscpN2DMkJDTYQ@mail.gmail.com> <20210216105145.03b5943b@firost>

* 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