title: READ COMMITTED lock wait timeout exceeded
body: <p>I have one question regarding transaction isolation level and locking in mysql.</p>
  
  <p>I have one query keeps getting the lock timeout error:</p>
  
  <pre><code>java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
  </code></pre>
  
  <p>The queries basically try to delete records with a specific date_id. BTW, the date_id is indexed as well. But most of the times, there are no records match, i.e. it will delete nothing.</p>
  
  <p>After some investigation, I found it may be caused by a culprit long-running query, which do a range select on the same table. However, what confused me is both transaction run at isolation level of "READ COMMITTED". So I have no clue why a lock is needed and why it could timeout (especially consider there is no matching record to delete)</p>
  
  <p>Thank you in advance!</p>