From b68d2d12f4dff73d371297688d84f32289c06907 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Sat, 29 Apr 2023 00:23:36 -0400 Subject: [PATCH 1/1] 20447: Don't lock containers table for CR name/description updates. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- .../arvados/v1/container_requests_controller.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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 75f70b1a2d..586567cb29 100644 --- a/services/api/app/controllers/arvados/v1/container_requests_controller.rb +++ b/services/api/app/controllers/arvados/v1/container_requests_controller.rb @@ -38,10 +38,18 @@ class Arvados::V1::ContainerRequestsController < ApplicationController 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 EXCLUSIVE MODE" + if (resource_attrs.keys - [:owner_uuid, :name, :description, :properties]).empty? + # If no attributes are being updated besides these, there are no + # cascading changes to other rows/tables, so we should just use + # row locking. + @object.reload(lock: true) super + else + # Lock containers table to avoid deadlock in cascading priority update (see #20240) + Container.transaction do + ActiveRecord::Base.connection.execute "LOCK TABLE containers IN EXCLUSIVE MODE" + super + end end end end -- 2.30.2