auto_increment jumps by 3 and not 1

2.6k Views Asked by At

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)
2

There are 2 best solutions below

0
On BEST ANSWER

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/

2
On

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%';