[MDEV-30865] Sequences discard all cache values when altered Created: 2023-03-16  Updated: 2023-05-02

Status: Open
Project: MariaDB Server
Component/s: Sequences
Affects Version/s: 11.0
Fix Version/s: 11.0

Type: Bug Priority: Major
Reporter: Yuchen Pei Assignee: Yuchen Pei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

https://lists.launchpad.net/maria-developers/msg13299.html

Sequences will skip all cached value at alter.

d77aaa6994b 11.0

create sequence s;
select next value for s; # 1
alter sequence s cycle;
select next value for s; # 1001, because the default cache size is 1000 and reserved_until is 1001
drop sequence s;

It becomes worse when we throw in as <int_type> (Item 1 or MDEV-28152):

create sequence s as tinyint;
select next value for s;
alter sequence s maxvalue 63;
select next value for s; # error: ER_SEQUENCE_RUN_OUT, because default cache size 1000 is out of range for tiny int, and no maxvalue will work.
drop sequence s;

This may be related to the documented behaviour[1] of discarding cached values when flushing tables. Presumably this makes server restart also do the same.

create sequence s;
select next value for s; # 1
flush tables;
select next value for s; # 1001
drop sequence s;
 
create sequence s;
select next value for s; # 1
--source include/restart_mysqld.inc
select next value for s; # 1001
drop sequence s;

[1] https://mariadb.com/kb/en/sequence-overview/#notes

Shall we
1. treat the alter-discard behaviour as a bug and fix it, OR
2. treat the alter-discard behaviour as intended, just like flush tables, OR
3. treat all cache discard behaviours as a bug and fix them?

CC monty serg


Generated at Thu Feb 08 10:19:28 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.