Actions
Bug #11546
closedExpensive container lock/unlock
Story points:
-
Description
Currently the "lock" and "unlock" operations aquire a table lock. This causes ActiveRecord to reload the record. If loading the record is expensive (eg #11547) this means the lock can be held for a long time, which effectively paralyzes the containers table.
Change lock to do:
"update container set state=Locked where uuid=X and state=Queued"
and unlock:
"update container set state=Queued where uuid=X and state=Locked"
and use the number of rows updated (1 or 0) to determine success.
#<ArvadosModel::InvalidStateTransitionError: ArvadosModel::InvalidStateTransitionError> /var/www/arvados-api/current/app/models/container.rb:224:in `block in unlock' /var/www/arvados-api/shared/vendor_bundle/ruby/2.3.0/gems/activerecord-3.2.22.5/lib/active_record/locking/pessimistic.rb:72:in `block in with_lock' /var/www/arvados-api/shared/vendor_bundle/ruby/2.3.0/gems/activerecord-3.2.22.5/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction' /var/www/arvados-api/shared/vendor_bundle/ruby/2.3.0/gems/activerecord-3.2.22.5/lib/active_record/transactions.rb:208:in `transaction' /var/www/arvados-api/shared/vendor_bundle/ruby/2.3.0/gems/activerecord-3.2.22.5/lib/active_record/transactions.rb:250:in `transaction' /var/www/arvados-api/shared/vendor_bundle/ruby/2.3.0/gems/activerecord-3.2.22.5/lib/active_record/locking/pessimistic.rb:70:in `with_lock' /var/www/arvados-api/current/app/models/container.rb:222:in `unlock' /var/www/arvados-api/current/app/controllers/arvados/v1/containers_controller.rb:33:in `unlock' ... Error 1493151643+9496f4a1: 422 {"method":"POST","path":"/arvados/v1/containers/qr1hi-dz642-wu9psm8wa0fnxnf/unlock","format":"html","controller":"arvados/v1/containers","action":"unlock","status":422,"duration":88029.34,"view":0.58,"db":1109.73,"params":{},"@timestamp":"2017-04-25T20:20:43.942319294Z","@version":"1","message":"[422] POST /arvados/v1/containers/qr1hi-dz642-wu9psm8wa0fnxnf/unlock (arvados/v1/containers#unlock)"}
Duration of this request is 88 seconds!
Actions