2

I have noticed that in my mysql server, the auto_increment setting increments by 3, for example 3 6 9 12 15 etc.

All the tables in the database are having the same problem.

I'm using mariadb 10.5 on debian 10.

Could it be because of having a 3 vps galley cluster?

MariaDB [(none)]> SHOW VARIABLES LIKE 'auto_inc%';
+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| auto_increment_increment | 3     |
| auto_increment_offset    | 1     |
+--------------------------+-------+
2 rows in set (0.002 sec)
Paulo Boaventura
  • 1,365
  • 1
  • 9
  • 29
diaconu liviu
  • 1,032
  • 2
  • 13
  • 30

2 Answers2

3

They designed it to be like that. You could say that it is a limitation of using Galera. They made it like that to address the collision issue when generating sequential numbers as primary key during inserts in a Multi-Master cluster.

https://mariadb.org/auto-increments-in-galera/

Nikko Gagala
  • 84
  • 10
2

If you are actually using Galera, then auto_increment_increment needs to be 3 (or however many nodes (servers) are in the cluster).

SHOW VARIABLES LIKE 'wsrep%';

Rick James
  • 135,179
  • 13
  • 127
  • 222
  • Yes, I use galera, then it is normal to be 3 in 3. And this does not affect that the id int255 ends 3 times faster than 1 in 1? – diaconu liviu Sep 17 '20 at 10:30
  • 1
    @diaconuliviu - What is int255? If you mean `TINYINT UNSIGNED`, then yes, each node can insert about 85 rows before overflowing. Take that into account when specifying datatypes. Meanwhile `auto_increment_offset` should be 3 different values for the 3 nodes. If you insert only into one node, then 85 rows is the limit. If you insert in just the right way spread across 3 nodes, it won't overflow before about 255 rows. – Rick James Sep 17 '20 at 18:05