I'm seeing these errors flooding my log file.
They come from commerce order complete pages - and some registration pages too.
Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '813' for key 'users.PRIMARY': INSERT INTO "users" ("uuid", "langcode") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array ( [:db_insert_placeholder_0] => 62100ab3-1cba-49e4-98ea-af0f74d6dc09 [:db_insert_placeholder_1] => en ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 815 of /etc/apache2/htdocs/drupal-8/neway-drupal-project/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
With a little further digging - I can see that the Auto_increment on the Users table is out of synch with the max value of uid.
Running:
SHOW TABLE STATUS WHERE `Name` = 'users';
Gives:
814 in the Auto_incerment column
Running:
select max(uid) from users;
Gives:
1392
So this explains the reason.
So the question is - how can I safely reset the auto_increment value without breaking any other Drupal dependencies?