title: DB2 lock timeout
body: <p>We have a WebSphere cluster with four clones.  Identical code runs on each of the clones.  We have Quartz periodically kick off a job that runs the code.</p>
  
  <p>The code tries to update a row in a table so that only one of the clones will be able to successfully update the table, and then that clone will run the rest of the job.  Something like:</p>
  
  <pre><code>update &lt;table&gt; set status = 'RUNNING' where job_name = 'JOB1' and status = 'STOPPED'
  </code></pre>
  
  <p>We do not start a transaction when we execute the update statement.</p>
  
  <p>What we see sometimes is that all four clones fail to update the table, and all get a lock timeout error (sql code -913).</p>
  
  <p>We've also tried an alternative where we start a transaction, select to see if the row is marked as running, and if not, then performing an update and committing; and otherwise rolling back.</p>
  
  <p>That had the same problem.</p>
  
  <p>One solution we did not try yet is to modify the select to be a "select for update" although from my googleing, I have doubts as to whether that will help.</p>
  
  <p>Any suggestions?</p>