jqueue: Fix deadlock between job queue and dependency manager
authorMichael Hanselmann <hansmi@google.com>
Mon, 19 Dec 2011 15:26:55 +0000 (16:26 +0100)
committerMichael Hanselmann <hansmi@google.com>
Wed, 21 Dec 2011 14:35:50 +0000 (15:35 +0100)
commit37d76f1e44a914f67a9a2a85f2261fae7243a734
tree16715e2d2a1993f9ce467ecb95a8ba9c926edfd5
parent1d4930b92c80856770ba779aa4bd885799dd8594
jqueue: Fix deadlock between job queue and dependency manager

When an opcode is about to be processed its dependencies are
evaluated using “_JobDependencyManager.CheckAndRegister”. Due
to its nature that function requires a lock on the manager's
internal structures. All of this happens while the job queue
lock is held in shared mode (required for the job processor).

When a job has been processed any pending dependencies are re-added
to the job workerpool. Before this patch that would require
the manager's lock and then, for adding the jobs, the job queue
lock. Since this is in reverse order it will lead to deadlocks.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
lib/jqueue.py
test/ganeti.jqueue_unittest.py