Re: Sequences / Replication - Mailing list pgsql-general

From Albe Laurenz
Subject Re: Sequences / Replication
Date
Msg-id A737B7A37273E048B164557ADEF4A58B5395F128@ntex2010a.host.magwien.gv.at
Whole thread Raw
In response to Sequences / Replication  (Jonathan Eastgate <jonathan.eastgate@simpro.co>)
List pgsql-general
Jonathan Eastgate wrote:
> We're seeing some odd behaviour from a PostgreSQL group - one running as primary and the other as a
> hot slave using streaming replication.
> 
> When a failover event occurs and we switch to the hot slave as primary sequences in tables jump by 33
> - so where the last number allocated in the sequence was 100 prior to failover once adding the next
> entry the sequence will produce the number 133.

That is working as expected.

When nextval() is called, a number of sequence numbers are reserved (by default one,
you can set this with the CACHE clause of CREATE SEQUENCE).  If the transaction is aborted,
these entries won't be used.

So if there were 30 inserting transactions when your server went down that got aborted,
that would explain the behaviour quite nicely.

This should not be a problem.

Yours,
Laurenz Albe

pgsql-general by date:

Previous
From: wd
Date:
Subject: Re: Postgres upgrade from 9.4.9 to 9.6 using pg_upgrade error
Next
From: "Jaisingkar, Piyush"
Date:
Subject: sending records from one function to other with dblink