Thread: BUG #15010: Sequence ID is getting skipped

BUG #15010: Sequence ID is getting skipped

From
PG Bug reporting form
Date:
The following bug has been logged on the website:

Bug reference:      15010
Logged by:          Anil Kumar G V
Email address:      anilkumar.gv@gmail.com
PostgreSQL version: 9.3.0
Operating system:   Ubuntu
Description:

Sometime sequence ID is getting skipped by 32 numbers. Here is some sample
sequence definition. 

  Column     |  Type   |        Value         
---------------+---------+----------------------
 sequence_name | name    | audit_logid_sequence
 last_value    | bigint  | 425585242
 start_value   | bigint  | 1
 increment_by  | bigint  | 1
 max_value     | bigint  | 9223372036854775807
 min_value     | bigint  | 1
 cache_value   | bigint  | 1
 log_cnt       | bigint  | 24
 is_cycled     | boolean | f
 is_called     | boolean | t


      Sequence "nmc.mrno_number_seq"
    Column     |  Type   |        Value        
---------------+---------+---------------------
 sequence_name | name    | mrno_number_seq
 last_value    | bigint  | 12
 start_value   | bigint  | 1
 increment_by  | bigint  | 1
 max_value     | bigint  | 9223372036854775807
 min_value     | bigint  | 1
 cache_value   | bigint  | 1
 log_cnt       | bigint  | 0
 is_cycled     | boolean | f
 is_called     | boolean | t




BUG #15010: Sequence ID is getting skipped

From
"David G. Johnston"
Date:
On Sunday, January 14, 2018, PG Bug reporting form <noreply@postgresql.org> wrote:
The following bug has been logged on the website:

Bug reference:      15010
Logged by:          Anil Kumar G V
Email address:      anilkumar.gv@gmail.com
PostgreSQL version: 9.3.0
Operating system:   Ubuntu
Description:

Sometime sequence ID is getting skipped by 32 numbers. Here is some sample
sequence definition.

I don't think the exact cause of this particular skipping is documented (it's database startup, maybe crash, related I think) but sequences are not promised to be gap-less.

David J.

Re: BUG #15010: Sequence ID is getting skipped

From
Daniel Gustafsson
Date:
> On 15 Jan 2018, at 08:36, David G. Johnston <david.g.johnston@gmail.com> wrote:
>
> On Sunday, January 14, 2018, PG Bug reporting form <noreply@postgresql.org <mailto:noreply@postgresql.org>> wrote:
> The following bug has been logged on the website:
>
> Bug reference:      15010
> Logged by:          Anil Kumar G V
> Email address:      anilkumar.gv@gmail.com <mailto:anilkumar.gv@gmail.com>
> PostgreSQL version: 9.3.0
> Operating system:   Ubuntu
> Description:
>
> Sometime sequence ID is getting skipped by 32 numbers. Here is some sample
> sequence definition.
>
> I don't think the exact cause of this particular skipping is documented (it's database startup, maybe crash, related
Ithink) but sequences are not promised to be gap-less. 

Sequences are indeed not guaranteed to be gapless, and given that the report is
for 32 numbers it sounds like the SEQ_LOG_VALS skipping. From sequence.c:

/*
 * We don't want to log each fetching of a value from a sequence,
 * so we pre-log a few fetches in advance. In the event of
 * crash we can lose (skip over) as many values as we pre-logged.
 */
#define SEQ_LOG_VALS    32

cheers ./daniel