Revision 0f933d15

b/Makefile.am
139 139
	doc/examples/ganeti.initd.in \
140 140
	doc/examples/ganeti.cron.in \
141 141
	doc/examples/dumb-allocator \
142
	doc/locking.txt \
142 143
	test/testutils.py \
143 144
	test/mocks.py \
144 145
	$(dist_TESTS) \
b/doc/locking.txt
1
Introduction:
2

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

  
6

  
7
Opcode Execution Locking:
8

  
9
These locks are declared by Logical Units (LUs) (in cmdlib.py) and acquired by
10
the Processor (in mcpu.py) with the aid of the Ganeti Locking Library
11
(locking.py). They are acquired in the following order:
12

  
13
  * BGL: this is the Big Ganeti Lock, it exists for retrocompatibility. New LUs
14
    acquire it in a shared fashion, and are able to execute all toghether
15
    (baring other lock waits) while old LUs acquire it exclusively and can only
16
    execute one at a time, and not at the same time with new LUs.
17
  * Instance locks: can be declared in ExpandNames() o DeclareLocks() by an LU,
18
    and have the same name as the instance itself. They are acquired as a set.
19
    Internally the locking library acquired them in alphabetical order.
20
  * Node locks: can be declared in ExpandNames() o DeclareLocks() by an LU, and
21
    have the same name as the node itself. They are acquired as a set.
22
    Internally the locking library acquired them in alphabetical order. Given
23
    this order it's possible to safely acquire a set of instances, and then the
24
    nodes they reside on.
25

  
26
The ConfigWriter (in config.py) is also protected by a SharedLock, which is
27
shared by functions that read the config and acquired exclusively by functions
28
that modify it. Since the ConfigWriter calls rpc.call_upload_file to all nodes
29
to distribute the config without holding the node locks, this call must be able
30
to execute on the nodes in parallel with other operations (but not necessarily
31
concurrently with itself on the same file, as inside the ConfigWriter this is
32
called with the internal config lock held.
33

  

Also available in: Unified diff