Re: Gap in sequence after fail-over - Mailing list pgsql-admin

From Simon Riggs
Subject Re: Gap in sequence after fail-over
Date
Msg-id BANLkTimG4iKHdZ=AZYu=7-V-bTq6BLPEOA@mail.gmail.com
Whole thread Raw
In response to Gap in sequence after fail-over  (Simon Luijk <simonluijk@gmail.com>)
List pgsql-admin
On Tue, Apr 12, 2011 at 9:28 AM, Simon Luijk <simonluijk@gmail.com> wrote:
> I have two test systems with Postgresql in Hot-standby configuration. The
> intention
> is to fail-over to the slave every so often. When ever we switch servers
> (fail-over)
> and start inserting data, the primary ids have a gap of ~30. From the
> following
> thread form 2001 it seems this maybe expected?
>
> http://archives.postgresql.org/pgsql-bugs/2001-12/msg00082.php
>
> With a Hot-standby set-up like this, that regularly switches, can I not rely
> on
> the sequence always incrementing by 1?

No, you can't.

Sequences cache their values for performance. Any crash or failover
will produce the same effect.

We might change that for switchovers but it would take some effort and
would still be the same if it crashes.

--
 Simon Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

pgsql-admin by date:

Previous
From: Simon Luijk
Date:
Subject: Gap in sequence after fail-over
Next
From: Fábio Gibon - Comex System
Date:
Subject: Shared_buffer limited by SO