8840: Use 'with_lock' instead of 'transaction' in Job.lock method.
[arvados.git] / services / api / app / models / job.rb
index afaae26375b6e8b1659205c439306cbb2e1d4eea..01154077fd5dd96b888912740315f3643d1a2ecb 100644 (file)
@@ -93,8 +93,7 @@ class Job < ArvadosModel
   end
 
   def lock locked_by_uuid
-    transaction do
-      self.reload
+    with_lock do
       unless self.state == Queued and self.is_locked_by_uuid.nil?
         raise AlreadyLockedError
       end