-
Notifications
You must be signed in to change notification settings - Fork 403
Description
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
- start tarantool
- create a sequence, space and the index with the sequence set.
- insert some records
- reset the sequence
- restart tarantool
- 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>