I've got a table that suddenly started throwing up these errors on every insert statement.
I've solved the problem once, but now it's back and (due to management pressure) I need to know the cause and guarantee that it does not happen again. Here's the relevant data:
- id: INT(11) PK AI
COUNT(id)
-- 274;MAX(id)
-- 309;SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_name='groups'
-- 0- Engine: InnoDB
- Server uptime: 219091
I know how to fix the symptoms, now I need to find the source. Has anybody else tried digging deeper?
P.S.: None of my update/insert statements ever touch the id column.
Update, actions taken:
- Enabled binlog. Hopefully it won't fill the entire hdd before the error shows up again.
- Found an
insert ... id = $id ... where id = $id
situation. Shouldn't be the cause, but killed it with fire anyways. - Added a try..catch control in the spot I got the exception that resets AUTO_INCREMENT to 1 automagically and re-tries the erroneous query, in addition to manually logging the incident.
- Prayed that this works.