From: Lucas Di Pentima Date: Fri, 24 Jul 2020 20:12:27 +0000 (-0300) Subject: 16470: Fixes the last deprecation warnings. X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/571e9ea468feaa22ccf56b9585a36d6d84f1b8bd?hp=070bcb4e6afda609a371a5bfc7d0927f379e4531 16470: Fixes the last deprecation warnings. It turned out that .lock!() is an ActiveRecord method, and I was confusing it with Container::lock and ContainerRequest::lock. Both lock! and with_lock methods need the record to be persisted or reloaded explicitly. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- diff --git a/services/api/app/models/container_request.rb b/services/api/app/models/container_request.rb index 77536eee4f..16b4973216 100644 --- a/services/api/app/models/container_request.rb +++ b/services/api/app/models/container_request.rb @@ -123,10 +123,10 @@ class ContainerRequest < ArvadosModel while true # get container lock first, then lock current container request # (same order as Container#handle_completed). Locking always - # reloads the Container and ContainerRequest records. + # requires explicit Container and ContainerRequest records reload. c = Container.find_by_uuid(container_uuid) - c.lock! if !c.nil? - self.lock! + c.reload.lock! if !c.nil? + self.reload.lock! if !c.nil? && container_uuid != c.uuid # After locking, we've noticed a race, the container_uuid is @@ -263,7 +263,7 @@ class ContainerRequest < ArvadosModel if state_changed? and state == Committed and container_uuid.nil? while true c = Container.resolve(self) - c.lock! + c.reload.lock! if c.state == Container::Cancelled # Lost a race, we have a lock on the container but the # container was cancelled in a different request, restart