Revision a25c1b2a

b/doc/locking.txt
1
Introduction:
1
Ganeti locking
2
==============
3

  
4
Introduction
5
------------
2 6

  
3 7
This document describes lock order dependencies in Ganeti.
4 8
It is divided by functional sections
5 9

  
6 10

  
7
Opcode Execution Locking:
11
Opcode Execution Locking
12
------------------------
8 13

  
9 14
These locks are declared by Logical Units (LUs) (in cmdlib.py) and acquired by
10 15
the Processor (in mcpu.py) with the aid of the Ganeti Locking Library
......
31 36
concurrently with itself on the same file, as inside the ConfigWriter this is
32 37
called with the internal config lock held.
33 38

  
39

  
40
Job Queue Locking
41
-----------------
42

  
43
The job queue is designed to be thread-safe. This means that its public
44
functions can be called from any thread. One must only pay attention not to
45
call the job queue from functions called by the queue itself (e.g. logical
46
units).
47

  
48
The single queue lock is used from all classes involved in the queue handling.
49
During development we tried to split locks, but demmed it to be too dangerous
50
and difficicult at the time. Once the lock is held, all functions called must
51
not grab the queue lock again (e.g. call only functions with a ``Unlocked``
52
suffix).
53

  
54
In the job queue worker (``_JobQueueWorker``), the lock must be released before
55
calling the LU processor. Otherwise a deadlock can occur when log messages are
56
added to opcode results.
57

  
58

  
59
Node Daemon Locking
60
-------------------
61

  
62
The node daemon contains a lock for the job queue. In order to avoid conflicts
63
and/or corruption when an eventual master daemon or another node daemon is
64
running, it must be held for all job queue operations
65

  
66
There's one special case for the node daemon running on the master node. If
67
grabbing the lock in exclusive fails on startup, the code assumes all checks
68
have been done by the process keeping the lock.

Also available in: Unified diff