title: MySQL - Duplicated values in auto-incremented field
body: <p>I have a partitioned InnoDB table that looks something like this:</p>
  <pre><code>CREATE TABLE `actions` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `⁯id_user` int(11) NOT NULL,
    `created_at` datetime NOT NULL,
    PRIMARY KEY (`id`,`⁯id_user`),
    KEY `⁯id_user` (`⁯id_user`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
  /*!50100 PARTITION BY RANGE (⁯id_user)
  (PARTITION p01 VALUES LESS THAN (100000) ENGINE = InnoDB,
   PARTITION p02 VALUES LESS THAN (200000) ENGINE = InnoDB,
   PARTITION p03 VALUES LESS THAN (300000) ENGINE = InnoDB,
   PARTITION p04 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */;
  </code></pre>
  <p>There are inserts and updates in the tens of thousands per minute on this table.<br />
  From time to time, I'm getting duplicated values in the <code>id</code>, which is an auto-increment field.<br />
  Inserts don't have an <code>id</code> specified. There could be a single row inserted or multiple rows at once.<br />
  I'm using MySQL 5.7.26 and there's replication involved but there was no restart when this happened and all the inserts are made on the same server.</p>
  <p>These are some of the settings:</p>
  <pre><code>innodb_autoinc_lock_mode 1
  auto_increment_increment 1
  </code></pre>
  <p>Is there a way to avoid this from happening?</p>