title: Are long mysql transactions (~30 seconds) with only insert queries an issue? (InnoDB)
body: <p>I'm working on a PHP script that processes files and inserts information about the files into a database.</p>
  
  <p>Specifically, the script processes some info then begins a transaction and inserts it into a table. I then use <code>lastinsertid</code> to get the <code>ID</code> of the just inserted row, and use that <code>ID</code> in processing the associated file. When the processing completes (takes anywhere from 2-30 seconds) I do a few more inserts into other tables and complete the transaction after checking file processing was successful.</p>
  
  <p>So basically the rundown is this:</p>
  
  <pre><code>START TRANSACTION
  
  INSERT DATA INTO TABLE 1
  
  PROCESS FILE USING INSERT ID (takes 2-30 seconds)
  
  INSERT DATA INTO TABLE 2
  
  INSERT DATA INTO TABLE 3
  
  INSERT DATA INTO TABLE 4
  
  //VERIFY FILE PROCESSING    
    if ($file_process == true){   
  COMMIT   
  }   
  else{   
  ROLLBACK   
  }   
  </code></pre>
  
  <p>I know that long transactions are to be avoided due to the issues around holding locks for a long time, but what if the transaction only uses inserts. Since inserts only lock the row that is being inserted is this still an issue?</p>
  
  <p>Can someone explain to me the potential "gotchas" that could arise from this situation? I'm pretty sure that if one session's process is taking a long time and another session begins their own process, <code>session 1</code>will not block <code>session 2</code>, since the processes only deal with inserts. And if <code>session 1</code> fails and has to rollback, it will have no impact on <code>session 2</code> whatsoever (other than in the database there will be a gap in the auto-incrementing primary IDs but that doesn't matter)</p>