Re:Postgres sequences can skip 32 unexpectedly
by adeel_siddiqui on Friday July 16, 2021 @10:56AM
(#27856890)
Nice write-up. Something does not add up here though.
Primary writes 32 ahead to the WAL when fetched the first time, then keeps a counter (log_cnt) which it decreases each time nextval is called.
So, when sequence was initialized, nextval is 1 and WAL has 32.
The replica sees 32 as fetched offset.
How does incident sequence switch from 7 to 39? Shouldn't it be 33 when the replica was made the primary?
Same for incident 20 -> 52, shouldn't it be 33 when replica was made primary?
Unless I am missing something here, i.e, 32 is added to the nextval and nextval is logged each time (20 or 7).
[ Parent
| on HN ]
Re:Postgres sequences can skip 32 unexpectedly
by rcthompson on Friday July 16, 2021 @11:45AM
(#27857501)
Maybe it "tops up" the logged values whenever the database is idle?