[arvados] updated: 2.5.0-325-gba0f1def6

git repository hosting git at public.arvados.org
Fri Mar 31 15:14:55 UTC 2023


Summary of changes:
 .../arvados/v1/container_requests_controller.rb          | 16 ++++++++++++++++
 .../app/controllers/arvados/v1/containers_controller.rb  | 14 ++++++++++----
 2 files changed, 26 insertions(+), 4 deletions(-)

       via  ba0f1def68f8a42712175f123f12a8203731f2d0 (commit)
      from  9a091bcbde77e6595f7e565ab442bc223672276c (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 ba0f1def68f8a42712175f123f12a8203731f2d0
Author: Tom Clegg <tom at curii.com>
Date:   Fri Mar 31 11:14:19 2023 -0400

    20240: Lock containers table before cascading priority updates.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/services/api/app/controllers/arvados/v1/container_requests_controller.rb b/services/api/app/controllers/arvados/v1/container_requests_controller.rb
index 07b8098f5..86b4b6486 100644
--- a/services/api/app/controllers/arvados/v1/container_requests_controller.rb
+++ b/services/api/app/controllers/arvados/v1/container_requests_controller.rb
@@ -28,4 +28,20 @@ class Arvados::V1::ContainerRequestsController < ApplicationController
         },
       })
   end
+
+  def create
+    # Lock containers table to avoid deadlock in cascading priority update (see #20240)
+    Container.transaction do
+      ActiveRecord::Base.connection.execute "LOCK TABLE containers IN SHARE ROW EXCLUSIVE MODE"
+      super
+    end
+  end
+
+  def update
+    # Lock containers table to avoid deadlock in cascading priority update (see #20240)
+    Container.transaction do
+      ActiveRecord::Base.connection.execute "LOCK TABLE containers IN SHARE ROW EXCLUSIVE MODE"
+      super
+    end
+  end
 end
diff --git a/services/api/app/controllers/arvados/v1/containers_controller.rb b/services/api/app/controllers/arvados/v1/containers_controller.rb
index 20e7d6272..73701b92c 100644
--- a/services/api/app/controllers/arvados/v1/containers_controller.rb
+++ b/services/api/app/controllers/arvados/v1/containers_controller.rb
@@ -29,7 +29,9 @@ class Arvados::V1::ContainersController < ApplicationController
   end
 
   def update
-    @object.with_lock do
+    # Lock containers table to avoid deadlock in cascading priority update (see #20240)
+    Container.transaction do
+      ActiveRecord::Base.connection.execute "LOCK TABLE containers IN SHARE ROW EXCLUSIVE MODE"
       super
     end
   end
@@ -59,9 +61,13 @@ class Arvados::V1::ContainersController < ApplicationController
   end
 
   def update_priority
-    @object.reload(lock: true)
-    @object.update_priority!
-    show
+    # Lock containers table to avoid deadlock in cascading priority update (see #20240)
+    Container.transaction do
+      ActiveRecord::Base.connection.execute "LOCK TABLE containers IN SHARE ROW EXCLUSIVE MODE"
+      @object.reload(lock: true)
+      @object.update_priority!
+      show
+    end
   end
 
   def current

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list