title: Failed to read auto-increment value from storage engine. Cause?
body: <p>I've got a table that suddenly started throwing up these errors on every insert statement.</p>
  
  <p>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:</p>
  
  <ul>
  <li>id: INT(11) PK AI</li>
  <li><code>COUNT(id)</code> -- 274;</li>
  <li><code>MAX(id)</code> -- 309;</li>
  <li><code>SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_name='groups'</code> -- 0</li>
  <li>Engine: InnoDB</li>
  <li>Server uptime: 219091</li>
  </ul>
  
  <p>I know how to fix the symptoms, now I need to find the source. Has anybody else tried digging deeper?</p>
  
  <p>P.S.: None of my update/insert statements ever touch the id column.</p>
  
  <p><strong>Update, actions taken:</strong></p>
  
  <ul>
  <li>Enabled binlog. Hopefully it won't fill the entire hdd before the error shows up again.</li>
  <li>Found an <code>insert ... id = $id ... where id = $id</code> situation. Shouldn't be the cause, but killed it with fire anyways.</li>
  <li>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.</li>
  <li>Prayed that this works.</li>
  </ul>