Thread: Re: pg_ctl stop -m immediate on the primary server inflates sequences

Re: pg_ctl stop -m immediate on the primary server inflates sequences

From
Bernd Helmle
Date:

--On 10. April 2010 09:26:41 +0200 Boszormenyi Zoltan <zb@cybertec.at> 
wrote:

> The above is quite reproducable, "pg_ctl stop -m immediate"
> "usually" inflated my serial sequence, but I had two occasions
> when not. The 69 -> 70 was one. The inflated increase is always 33:

AFAIKS sequences are pre-logged with 32 values to WAL to avoid overhead. I 
suspect this is why you are seeing those gaps.

-- 
Thanks
Bernd


Re: pg_ctl stop -m immediate on the primary server inflates sequences

From
Boszormenyi Zoltan
Date:
Bernd Helmle írta:
>
>
> --On 10. April 2010 09:26:41 +0200 Boszormenyi Zoltan <zb@cybertec.at>
> wrote:
>
>> The above is quite reproducable, "pg_ctl stop -m immediate"
>> "usually" inflated my serial sequence, but I had two occasions
>> when not. The 69 -> 70 was one. The inflated increase is always 33:
>
> AFAIKS sequences are pre-logged with 32 values to WAL to avoid
> overhead. I suspect this is why you are seeing those gaps.

Then it should happen all the time, even with "-m fast" or "-m smart", no?

It seemed like my sequences have a CACHE 32 setting, which would
apply to every client that connects, runs nextval() once and disconnects.

But it didn't happen all the time, so it's not deterministic.

-- 
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/



Re: pg_ctl stop -m immediate on the primary server inflates sequences

From
Martijn van Oosterhout
Date:
On Sat, Apr 10, 2010 at 02:36:41PM +0200, Boszormenyi Zoltan wrote:
> >> The above is quite reproducable, "pg_ctl stop -m immediate"
> >> "usually" inflated my serial sequence, but I had two occasions
> >> when not. The 69 -> 70 was one. The inflated increase is always 33:
> >
> > AFAIKS sequences are pre-logged with 32 values to WAL to avoid
> > overhead. I suspect this is why you are seeing those gaps.
>
> Then it should happen all the time, even with "-m fast" or "-m smart", no?

Nope, because on a normal shutdown it writes out the actual value. When
you say "immediate" you mean "right now, don't bother with anything not
important", like for example gaps in sequences. You're essentially
crashing the DB.

Have a ncie day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patriotism is when love of your own people comes first; nationalism,
> when hate for people other than your own comes first.
>                                       - Charles de Gaulle

Re: pg_ctl stop -m immediate on the primary server inflates sequences

From
Boszormenyi Zoltan
Date:
Martijn van Oosterhout írta:
> On Sat, Apr 10, 2010 at 02:36:41PM +0200, Boszormenyi Zoltan wrote:
>   
>>>> The above is quite reproducable, "pg_ctl stop -m immediate"
>>>> "usually" inflated my serial sequence, but I had two occasions
>>>> when not. The 69 -> 70 was one. The inflated increase is always 33:
>>>>         
>>> AFAIKS sequences are pre-logged with 32 values to WAL to avoid
>>> overhead. I suspect this is why you are seeing those gaps.
>>>       
>> Then it should happen all the time, even with "-m fast" or "-m smart", no?
>>     
>
> Nope, because on a normal shutdown it writes out the actual value. When
> you say "immediate" you mean "right now, don't bother with anything not
> important", like for example gaps in sequences. You're essentially
> crashing the DB.
>
> Have a ncie day,
>   

OK, thanks for the info.

-- 
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/