title: PHP repeatedly updating and inserting into Innodb, update not finding correct records
body: <p>I am using MySQL with InnoDB plugin version 5.5 running on CentOS 6.6 x64 and PHP 5.5. The isolation level is set to REPEATABLE-READ.</p>
  
  <p>I am ingesting around 40,000 records into one table. If I only import around 500 records, everything works correctly. </p>
  
  <p>Some of these records may have overlapping date time ranges. If they do, then several steps are made in PHP. </p>
  
  <p>To check for overlapping records, a SELECT is done, if that returns empty, I can just insert the new record. If there is a record returned, then the below steps occur.</p>
  
  <ol>
  <li>Invalidate the older of the two overlapping records (record A)</li>
  <li>Copy the non-overlapping section of the older record into a new record (record C) and insert that record</li>
  <li>Insert the newer of the two overlapping records (record B)</li>
  </ol>
  
  <p>When I run the ingest for the 40,000 record case, I can see overlapping date ranges, meaning that the select query returned nothing, and then caused the special overlap handling to not trigger. Again, in smaller ingest cases all of that logic works fine and I've looked at the same specific overlap date ranges in both cases.</p>
  
  <p>At this point, it seems to me like the insert commit is not being seen in the next loop of the logic when the next select overlap check happens.</p>
  
  <p>I started looking into options with table locking, transactions, and isolation levels, but am not sure what the best approach is there.</p>