Project

General

Profile

Actions

Bug #11546

closed

Expensive container lock/unlock

Added by Peter Amstutz about 7 years ago. Updated almost 7 years ago.

Status:
Resolved
Priority:
Normal
Assigned To:
Category:
-
Target version:
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!


Subtasks 1 (0 open1 closed)

Task #11587: Review 11546-fast-lockResolvedTom Clegg05/17/2017Actions

Related issues

Related to Arvados - Bug #11547: [API] Excessive memory and time consumed by API and dispatch when container fields (like "mounts") are largeNewActions
Related to Arvados - Bug #11549: [CWL] Avoid mounting individual filesResolvedPeter Amstutz04/27/2017Actions
Actions

Also available in: Atom PDF