title: mysql duplicate entry error when there is no duplicate entry (bulk load via php)
body: <p>I am using <strong>mysql (5.0.32-Debian_7etch6-log)</strong> and i've got a nightly running bulk load <strong>php (5.2.6)</strong> script <strong>(using Zend_DB (1.5.1)</strong> via PDO) which does the following:</p>
  
  <ol>
  <li>truncating a set of 4 'import' tables</li>
  <li>bulk inserting data into these 4 'import' tables (re-using ids that have previously been in the tables as well, but i truncated the whole table, so that shouldn't be an issue, right?)</li>
  <li>if everything goes well, rename the 'live' tables to 'temp', the 'import' tables to 'live' and then the 'temp' (old 'live') tables to 'import'</li>
  </ol>
  
  <p>This worked great for weeks. Now I am occassionally getting this, somewhere in the middle of the whole bulk loading process:</p>
  
  <p><code>SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '911' for key 1</code></p>
  
  <p>Mind you that, this is not the first id that has been in the table before the truncation already.  When I just start the script manually again, it works like a charm.</p>
  
  <p>Any ideas? leftover indexes, something to do with the renaming maybe?</p>
  
  <p>In addition, when I check the table for an entry with the id 911 afterwards, it is not even in there.</p>