X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/56b27b265791e8f1b023a7864365d92876c97eb8..98969e546c909ac2ee4256934b5339080598d252:/services/api/app/models/container.rb diff --git a/services/api/app/models/container.rb b/services/api/app/models/container.rb index b59604cb22..3c6c969bd2 100644 --- a/services/api/app/models/container.rb +++ b/services/api/app/models/container.rb @@ -131,7 +131,7 @@ class Container < ArvadosModel def update_priority! return if ![Queued, Locked, Running].include?(state) p = ContainerRequest. - where('container_uuid=? and priority>0', uuid). + where('container_uuid=? and priority>0 and state=?', uuid, ContainerRequest::Committed). select("priority, requesting_container_uuid, created_at"). lock(true). map do |cr| @@ -831,19 +831,17 @@ class Container < ArvadosModel ContainerRequest. where(requesting_container_uuid: uuid, state: ContainerRequest::Committed). - find_in_batches(batch_size: 10) do |batch| - batch.each do |cr| - leave_modified_by_user_alone do - cr.set_priority_zero - container_state = Container.where(uuid: cr.container_uuid).pluck(:state).first - if container_state == Container::Queued || container_state == Container::Locked - # If the child container hasn't started yet, finalize the - # child CR now instead of leaving it "on hold", i.e., - # Queued with priority 0. (OTOH, if the child is already - # running, leave it alone so it can get cancelled the - # usual way, get a copy of the log collection, etc.) - cr.update_attributes!(state: ContainerRequest::Final) - end + in_batches(of: 15).each_record do |cr| + leave_modified_by_user_alone do + cr.set_priority_zero + container_state = Container.where(uuid: cr.container_uuid).pluck(:state).first + if container_state == Container::Queued || container_state == Container::Locked + # If the child container hasn't started yet, finalize the + # child CR now instead of leaving it "on hold", i.e., + # Queued with priority 0. (OTOH, if the child is already + # running, leave it alone so it can get cancelled the + # usual way, get a copy of the log collection, etc.) + cr.update_attributes!(state: ContainerRequest::Final) end end end