Re: Sequence moves forward when failover is triggerred - Mailing list pgsql-general

From Tom Lane
Subject Re: Sequence moves forward when failover is triggerred
Date
Msg-id 8254.1341960491@sss.pgh.pa.us
Whole thread Raw
In response to Sequence moves forward when failover is triggerred  (Andy Chambers <achambers@mcna.net>)
Responses Re: Sequence moves forward when failover is triggerred  (Andy Chambers <achambers@mcna.net>)
List pgsql-general
Andy Chambers <achambers@mcna.net> writes:
> When testing the failover procedure, we noticed that when the new master
> comes up, some sequences have moved forward (by between 30 and 40).  I see
> there's a "cache" option when creating the sequence but we're not using
> that.

> Is this to be expected?

Yes.  This is an artifact of an optimization that reduces the number of
WAL records generated by nextval() calls --- server processes will write
WAL records that say they've consumed multiple sequence values ahead of
where they actually have.

AFAICS this is not distinguishably different from the case where a
transaction consumes that number of sequence values and then rolls back,
so I don't see much wrong with that optimization.

            regards, tom lane

pgsql-general by date:

Previous
From: Andy Chambers
Date:
Subject: Re: Do I need archive_mode = on for hot standby?
Next
From: Andy Chambers
Date:
Subject: Re: Sequence moves forward when failover is triggerred