MariaDB master to master replication auto increment is not sequential I have two master to master MariaDB server replication with the below settings:
server A with 192.168.1.100:
------------------------------
bind-address            = 0.0.0.0
server-id       = 1
log-bin         = &quot;mysql-bin&quot;
binlog-do-db        = wordpress
replicate-do-db     = wordpress
relay-log=&quot;mysql-relay-log&quot;
auto-increment-increment = 2
auto-increment-offset = 1

and:
Server B with 192.168.1.200:
---------------------------------
bind-address            = 0.0.0.0
server-id               = 2
log-bin                 = &quot;mysql-bin&quot;
binlog-do-db            = wordpress
replicate-do-db         = wordpress
relay-log=&quot;mysql-relay-log&quot;
auto-increment-increment = 2
auto-increment-offset = 2

The replication works great but I have problem with auto increments. As you see they are not sequential. For example:
Server A increments: 1, 3, 5, 7, 9 and ...
Server B increments: 2, 4, 6, 8 and ...
The problem occurs when I insert 2 records in server A and 1 record in server B, the total primary key of the table will look like this: ID : 1, 3, 4
As you see number two is missing because I have inserted two records in server A. But I need auto increment to generate sequential numbers since we use them as our invoice numbers.  Gaps can get us in trouble with TAX laws in our country.
I know this is the internal mechanism for MariaDB and MySQL databases in order to avoid duplicate keys. but I just wanted to know if there is an alternative HA solution for sequential index replication.
Thank you
All(?) INSERTs, including IODKU and REPLACE can burn ids, leading to gaps.  This happens with the statement is rolled back.  And for INSERT IGNORE when some UNIQUE triggers &quot;ignore&quot;.
Even without multi-master, you can get AUTO_INCREMENT values out of order.  This is because the auto_inc is grabbed when needed, but not replicated until COMMITted.  Replicas will see the ids out of order.
Bottom line:  AUTO_INCREMENT guarantees uniqueness, nothing else.
(Also, what Gordan says.)