Skip to content

Sequence state is not saved after reset and tarantool restart. #9871

@psergee

Description

@psergee

Bug description

Sequence state is not saved after reset and tarantool restart.

  • OS: Linux
  • OS Version: Ubuntu 23.10
  • Architecture: amd64

tarantool --version
Tarantool 2.11.2-0-g1bac2d257
Target: Linux-x86_64-RelWithDebInfo
Build options: cmake . -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_BACKTRACE=TRUE
Compiler: GNU-13.2.0
C_FLAGS: -fexceptions -funwind-tables -fasynchronous-unwind-tables -fno-common -fopenmp -msse2 -Wformat -Wformat-security -Werror=format-security -fstack-protector-strong -fPIC -fmacro-prefix-map=/home/psergee/work/tarantool=. -std=c11 -Wall -Wextra -Wno-gnu-alignof-expression -fno-gnu89-inline -Wno-cast-function-type
CXX_FLAGS: -fexceptions -funwind-tables -fasynchronous-unwind-tables -fno-common -fopenmp -msse2 -Wformat -Wformat-security -Werror=format-security -fstack-protector-strong -fPIC -fmacro-prefix-map=/home/psergee/work/tarantool=. -std=c++11 -Wall -Wextra -Wno-invalid-offsetof -Wno-gnu-alignof-expression -Wno-cast-function-type

Steps to reproduce

  1. start tarantool
  2. create a sequence, space and the index with the sequence set.
  3. insert some records
  4. reset the sequence
  5. restart tarantool
  6. insert new record

Actual behavior

The sequence is not reset and continues after the tarantool new start.
Here is an example:

tarantool> box.schema.sequence.create('id_seq', { if_not_exists = true })
box.schema.create_space('test', {
    format = {
        {'id', type='unsigned', is_nullable=false},
        {'name', type='string', is_nullable=false},
    },
    if_not_exists = true,
})
box.space.test:create_index('primary', {
    sequence = 'id_seq',
    if_not_exists = true
})
---
...

tarantool> box.space.test:insert{nil, 'aaa'}
---
- [1, 'aaa']
...

tarantool> box.space.test:insert{nil, 'bbb'}
---
- [2, 'bbb']
...

tarantool> box.sequence.id_seq:reset()
---
...

tarantool> 

$ tarantool
Tarantool 2.11.2-0-g1bac2d257
type 'help' for interactive help
tarantool> box.cfg{}
. . . 
---
...

tarantool> box.space.test:insert{nil, 'ccc'}
---
- [3, 'ccc']
...

Expected behavior

The sequence state is reset after tarantool stop and start.
This is how it works without restart after reset:

tarantool> box.space.test:insert{nil, 'aaa'}
---
- [1, 'aaa']
...

tarantool> box.space.test:insert{nil, 'bbb'}
---
- [2, 'bbb']
...

tarantool> box.sequence.id_seq:reset()
---
...

tarantool> box.space.test:insert{nil, 'ccc'}
---
- error: Duplicate key exists in unique index "primary" in space "test" with old tuple
    - [1, "aaa"] and new tuple - [1, "ccc"]
...

tarantool>

Metadata

Metadata

Assignees

Labels

2.11Target is 2.11 and all newer release/master branches3.2Target is 3.2 and all newer release/master branches3.3Target is 3.3 and all newer release/master branchesbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions