Fix Version/s: LAVA Community Project
Database accesses done by the dispatcher-master are partially atomic as we are using:
- transaction: the full block is executed. If an exception is raised, changes are rollbacked
- select_for_update: lock a row that will be updated in the block.
The select_for_update() is the right way to make calls atomic. However, PostgreSQL does not allow to use select_for_update() with JOIN.
So for the moment, we are only locking the Job table and not the Device one.
Doing two calls:
1/ Job.objects.select_for_update(). ...
should be enough to make the calls fully atomic.
But, if their is a path somewhere in lava that does the reverse we will have a deadlock.
So this task is to:
1/ make the dispatcher-master fully atomic (two select_for_update)
2/ check that lava-server is always blocking in the same order (job then device).