I saw the same error message on a table with a bigint(20) key and looking at the output of
mysql>show table status like 'my_big_table';
It showed:
Auto_increment: 0
when it should have been:
Auto_increment: 2157452851
(as the last row inserted had a key value of 2157452850)
There was no explanation of why the Auto_increment went to a value of 0 but it blocked inserts by our application.
I tried to do the ALTER TABLE
to change the Auto_increment value, but it was apparent that the entire table was going to be rebuilt, which on a table this size would have taken many hours, so I canceled the alter.
The solution I found was to explicitly add a row with the next key value:
mysql> INSERT INTO `my_big_table` VALUES (2157452851,22808084,71,36376,'2013-03-16 15:09:55','2013-03-16 15:07:18','2013-03-16 15:09:55','Sent',NULL,7426);
Query OK, 1 row affected (0.03 sec)
This corrected the Auto_index value.
mysql> show table status like 'my_big_table'\G
Auto_increment: 2157452852
Hopefully this will help someone else.