X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/764334dee966e04161d411a9feb0074b99faa147..0eedf70afa34167275d2135837e866b13fac4178:/services/api/app/models/container.rb diff --git a/services/api/app/models/container.rb b/services/api/app/models/container.rb index e9d4f83658..7ec9845bc1 100644 --- a/services/api/app/models/container.rb +++ b/services/api/app/models/container.rb @@ -5,6 +5,7 @@ require 'log_reuse_info' require 'whitelist_update' require 'safe_json' +require 'update_priority' class Container < ArvadosModel include ArvadosModelUpdates @@ -37,6 +38,7 @@ class Container < ArvadosModel before_save :scrub_secret_mounts after_save :handle_completed after_save :propagate_priority + after_commit { UpdatePriority.run_update_thread } has_many :container_requests, :foreign_key => :container_uuid, :class_name => 'ContainerRequest', :primary_key => :uuid belongs_to :auth, :class_name => 'ApiClientAuthorization', :foreign_key => :auth_uuid, :primary_key => :uuid @@ -126,7 +128,6 @@ class Container < ArvadosModel # Update the priority of child container requests to match new # priority of the parent container (ignoring requests with no # container assigned, because their priority doesn't matter). - ActiveRecord::Base.connection.execute('LOCK container_requests, containers IN EXCLUSIVE MODE') ContainerRequest. where(requesting_container_uuid: self.uuid, state: ContainerRequest::Committed). @@ -316,11 +317,7 @@ class Container < ArvadosModel # (because state might have changed while acquiring the lock). check_lock_fail transaction do - begin - reload(lock: 'FOR UPDATE NOWAIT') - rescue - raise LockFailedError.new("cannot lock: other transaction in progress") - end + reload check_lock_fail update_attributes!(state: Locked) end @@ -542,7 +539,6 @@ class Container < ArvadosModel if self.state_changed? and self.final? act_as_system_user do - ActiveRecord::Base.connection.execute('LOCK container_requests, containers IN EXCLUSIVE MODE') if self.state == Cancelled retryable_requests = ContainerRequest.where("container_uuid = ? and priority > 0 and state = 'Committed' and container_count < container_count_max", uuid) else