Skip to content

Lock TestJobs before scheduling to prevent race conditions with TestJob cancelling

Use select_for_update() and a transaction to prevent anyone from cancelling or failing jobs while the scheduler tries to schedule them.

Otherwise it is possible for a job to be cancelled while it is being scheduled. This can result in a Device getting stuck in the Reserved state which can only be removed with direct database manipulation.

Merge request reports