Project

General

Profile

Bug #8840

Updated by Peter Amstutz about 8 years ago

API server Job.lock uses a "transaction" but this doesn't guarantee atomic read-update-write operations.    Need to use "with_lock" instead. 

 http://api.rubyonrails.org/classes/ActiveRecord/Locking/Pessimistic.html 

 "with_lock" Wraps the passed block in a transaction, locking the object before yielding. You can pass the SQL locking clause as argument (see lock!)." 

 "lock!" Obtain a row lock on this record. Reloads the record to obtain the requested lock. Pass an SQL locking clause to append the end of the SELECT statement or pass true for “FOR UPDATE” (the default, an exclusive row lock). Returns the locked record. 

 Implemented in branch 8840-lock-job-record.

Back