简体   繁体   English

auto_increment 跳 3 而不是 1

[英]auto_increment jumps by 3 and not 1

I have noticed that in my mysql server, the auto_increment setting increments by 3, for example 3 6 9 12 15 etc.我注意到在我的 mysql 服务器中,auto_increment 设置增加了 3,例如 3 6 9 12 15 等。

All the tables in the database are having the same problem.数据库中的所有表都存在同样的问题。

I'm using mariadb 10.5 on debian 10.我在 debian 10 上使用 mariadb 10.5。

Could it be because of having a 3 vps galley cluster?可能是因为有一个 3 vps 厨房集群吗?

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)

如果您实际上使用的是 Galera,那么auto_increment_increment需要为 3(或者集群中有多少个节点(服务器))。

SHOW VARIABLES LIKE 'wsrep%';

They designed it to be like that.他们设计成这样。 You could say that it is a limitation of using Galera.你可以说这是使用 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/ https://mariadb.org/auto-increments-in-galera/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM