Statistics
| Branch: | Tag: | Revision:

root / doc / locking.txt @ 3fc175f0

History | View | Annotate | Download (1.7 kB)

1 0f933d15 Guido Trotter
Introduction:
2 0f933d15 Guido Trotter
3 0f933d15 Guido Trotter
This document describes lock order dependencies in Ganeti.
4 0f933d15 Guido Trotter
It is divided by functional sections
5 0f933d15 Guido Trotter
6 0f933d15 Guido Trotter
7 0f933d15 Guido Trotter
Opcode Execution Locking:
8 0f933d15 Guido Trotter
9 0f933d15 Guido Trotter
These locks are declared by Logical Units (LUs) (in cmdlib.py) and acquired by
10 0f933d15 Guido Trotter
the Processor (in mcpu.py) with the aid of the Ganeti Locking Library
11 0f933d15 Guido Trotter
(locking.py). They are acquired in the following order:
12 0f933d15 Guido Trotter
13 0f933d15 Guido Trotter
  * BGL: this is the Big Ganeti Lock, it exists for retrocompatibility. New LUs
14 0f933d15 Guido Trotter
    acquire it in a shared fashion, and are able to execute all toghether
15 0f933d15 Guido Trotter
    (baring other lock waits) while old LUs acquire it exclusively and can only
16 0f933d15 Guido Trotter
    execute one at a time, and not at the same time with new LUs.
17 0f933d15 Guido Trotter
  * Instance locks: can be declared in ExpandNames() o DeclareLocks() by an LU,
18 0f933d15 Guido Trotter
    and have the same name as the instance itself. They are acquired as a set.
19 0f933d15 Guido Trotter
    Internally the locking library acquired them in alphabetical order.
20 0f933d15 Guido Trotter
  * Node locks: can be declared in ExpandNames() o DeclareLocks() by an LU, and
21 0f933d15 Guido Trotter
    have the same name as the node itself. They are acquired as a set.
22 0f933d15 Guido Trotter
    Internally the locking library acquired them in alphabetical order. Given
23 0f933d15 Guido Trotter
    this order it's possible to safely acquire a set of instances, and then the
24 0f933d15 Guido Trotter
    nodes they reside on.
25 0f933d15 Guido Trotter
26 0f933d15 Guido Trotter
The ConfigWriter (in config.py) is also protected by a SharedLock, which is
27 0f933d15 Guido Trotter
shared by functions that read the config and acquired exclusively by functions
28 0f933d15 Guido Trotter
that modify it. Since the ConfigWriter calls rpc.call_upload_file to all nodes
29 0f933d15 Guido Trotter
to distribute the config without holding the node locks, this call must be able
30 0f933d15 Guido Trotter
to execute on the nodes in parallel with other operations (but not necessarily
31 0f933d15 Guido Trotter
concurrently with itself on the same file, as inside the ConfigWriter this is
32 0f933d15 Guido Trotter
called with the internal config lock held.