How to reproduce:
1. Install old MySQL (I was using Percona).
2. Create a table with auto_increment = something
3. Insert some rows
4. Upgrade to MariaDB 10.2
5. Inserting new rows causes Duplicate entry 'xxx' for key 'PRIMARY'
I think this issue is related to how MariaDB 10.2 handles auto_increment. Before, it would recalculate the next auto_increment every time the server was started. Now it is persistent, but after an upgrade, it uses the old auto_increment that was in the initial create table statement.
A workaround is to remove the auto increment and add it again.