[ARVADOS] updated: 78390940029ab08efecab923615c545b9da922b4

Git user git at public.curoverse.com
Wed May 17 14:30:37 EDT 2017


Summary of changes:
 services/api/app/models/container.rb | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

       via  78390940029ab08efecab923615c545b9da922b4 (commit)
      from  fbc576b76977938cf7b742f9770ab90559136dc8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 78390940029ab08efecab923615c545b9da922b4
Author: Tom Clegg <tom at curoverse.com>
Date:   Wed May 17 14:28:33 2017 -0400

    11546: Wrap lock/unlock in transactions.

diff --git a/services/api/app/models/container.rb b/services/api/app/models/container.rb
index 92ccb7c..a22d620 100644
--- a/services/api/app/models/container.rb
+++ b/services/api/app/models/container.rb
@@ -226,13 +226,15 @@ class Container < ArvadosModel
     # (because it's cheaper that way) and once after getting the lock
     # (because state might have changed while acquiring the lock).
     check_lock_fail
-    begin
-      reload(lock: 'FOR UPDATE NOWAIT')
-    rescue
-      raise LockFailedError.new("cannot lock: other transaction in progress")
+    transaction do
+      begin
+        reload(lock: 'FOR UPDATE NOWAIT')
+      rescue
+        raise LockFailedError.new("cannot lock: other transaction in progress")
+      end
+      check_lock_fail
+      update_attributes!(state: Locked)
     end
-    check_lock_fail
-    update_attributes!(state: Locked)
   end
 
   def check_unlock_fail
@@ -246,9 +248,11 @@ class Container < ArvadosModel
   def unlock
     # Check invalid state transitions twice (see lock)
     check_unlock_fail
-    reload(lock: 'FOR UPDATE')
-    check_unlock_fail
-    update_attributes!(state: Queued)
+    transaction do
+      reload(lock: 'FOR UPDATE')
+      check_unlock_fail
+      update_attributes!(state: Queued)
+    end
   end
 
   def self.readable_by(*users_list)

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list