DS NOTES Unit 4 PDF
DS NOTES Unit 4 PDF
DS NOTES Unit 4 PDF
UNIT IV
RECOVERY & CONSENSUS
CHECKPOINTING AND ROLLBACK RECOVERY
INTRODUCTION
1
CS8603 DISTRIBUTED SYSTEMS UNIT 4
System Model
o A distributed system consists of a fixed number of processes, P1, P2 …PN,
communicate only through messages.
o Processes cooperate to execute a distributed application and interact with
the outside world by receiving and sending input and output messages.
2
CS8603 DISTRIBUTED SYSTEMS UNIT 4
Local checkpoint
o All processes save their local states at certain instants of time. This saved
state is known as a local checkpoint.
o A local checkpoint is a snapshot of the state of the process at a given
instance.
o The event of recording the state of a process is called local
checkpointing.
o Assumption :
→ A process stores all local checkpoints on the stable storage.
→ A process is able to roll back to any of its existing local
checkpoints.
o Ci,k -- kth local checkpoint at process Pi.
o Ci,0 – A process Pi takes a checkpoint Ci,0 before it starts execution.
o A local checkpoint is shown in the process-line by the symbol “|”.
Consistent states
o Example:
o Message m1 to have been sent but not yet received. The state is
consistent because it represents a situation in which every message
that has been received, there is a corresponding message send event.
4
CS8603 DISTRIBUTED SYSTEMS UNIT 4
o Lost messages
→ Messages whose ‘send’ is done but ‘receive’ is undone due to
rollback.
→ This type of messages occurs when the process rolls back to a
checkpoint prior to reception of the message while the sender does
not rollback beyond the send operation of the message.
→ Message m1 is a lost message.
o Delayed messages
→ Messages whose ‘receive’ is not recorded because the receiving
process was either down or the message arrived after rollback.
→ Messages m2 and m5 are delayed messages.
5
CS8603 DISTRIBUTED SYSTEMS UNIT 4
o Orphan messages
→ Messages with ‘receive’ recorded but message ‘send’ not recorded.
→ Do not arise, if processes roll back to a consistent global state.
→ Orphan messages do not arise if processes roll back to a consistent
global state.
o Duplicate messages
→ Arise due to message logging and replaying during process
recovery.
→ Message m4 was sent and received before the rollback.
→ Due to the rollback of process P4 to C4,8 and process P3 to C3,8,
both send and receipt of message m4 are undone.
→ When process P3 restarts from C3,8, it will resend message m4.
Therefore, P4 should not replay message m4 from its log. If P4
replays message m4, then message m4 is called a duplicate
message.
Checkpoints : {Ci,0, C1,1}, {Cj,0 ,Cj,1, Cj,2}, and {Ck,0 ,Ck,1, Ck,2}
Messages :A-J
6
CS8603 DISTRIBUTED SYSTEMS UNIT 4
CHECKPOINT-BASED RECOVERY
7
CS8603 DISTRIBUTED SYSTEMS UNIT 4
o It does not rely on the PWD assumption, and so does not need to detect,
log, or replay non-deterministic events.
o Does not guarantee that prefailure execution can be deterministically
regenerated after a rollback.
o Checkpoint-based rollback-recovery techniques can be classified into
three types:
→ Uncoordinated checkpointing,
→ Coordinated checkpointing,
→ Communication-induced checkpointing
Uncoordinated checkpointing
8
CS8603 DISTRIBUTED SYSTEMS UNIT 4
o Steps:
→ When a failure occurs, the recovering process initiates rollback by
broadcasting a dependency request message to collect all the
dependency information maintained by each process.
→ When a process receives this message, it stops its execution and
replies with the dependency information saved on the stable
storage.
→ The initiator then calculates the recovery line based on the global
dependency information.
→ Then the initiator broadcasts a rollback request message
containing the recovery line.
→ Upon receiving this message, a process whose current state
belongs to the recovery line simply resumes execution;
→ Otherwise, it rolls back to an earlier checkpoint.
Coordinated checkpointing
o In coordinated checkpointing, processes orchestrate their
checkpointing activities so that all local checkpoints form a consistent
global state.
o Simplifies recovery.
o Not susceptible to the domino effect.
o Disadvantages :
→ Large latency is involved in committing output,
9
CS8603 DISTRIBUTED SYSTEMS UNIT 4
10
CS8603 DISTRIBUTED SYSTEMS UNIT 4
11
CS8603 DISTRIBUTED SYSTEMS UNIT 4
12
CS8603 DISTRIBUTED SYSTEMS UNIT 4
13
CS8603 DISTRIBUTED SYSTEMS UNIT 4
→ The first one starts with the creation of the process, while the
remaining three start with the receipt of messages m0, m3, and m7.
→ Send event of message m2 is uniquely determined by the initial
state of P0 and by the receipt of message m0, and is therefore not a
non-deterministic event.
o Log-based rollback recovery assumes that all non-deterministic
events can be identified and their corresponding determinants can be
logged into the stable storage.
o During failure-free operation, each process logs the determinants of all
non-deterministic events that it observes onto the stable storage.
14
CS8603 DISTRIBUTED SYSTEMS UNIT 4
PESSIMISTIC LOGGING
o Pessimistic protocols log to the stable storage the determinant of each
non-deterministic event before the event affects the computation.
o Pessimistic protocols implement the following property called as
synchronous logging.
o It is defined by :
∀e: ¬Stable(e) ⇒ |Depend(e)| = 0
o If an event has not been logged on the stable storage, then no process
can depend on it.
o Processes also take periodic checkpoints to minimize the amount of
work that has to be repeated during recovery.
o When a process fails, the process is restarted from the most recent
checkpoint and the logged determinants are used to recreate the
prefailure execution.
o Example :
→ During failure-free operation the logs of processes P0, P1, and P2
contain the determinants needed to replay messages m0, m4, m7,
m1, m3, m6, and m2, m5, respectively.
→ Suppose processes 𝑃1 and 𝑃2 fail as shown, restart from
checkpoints B and C, and roll forward using their determinant logs
to deliver again the same sequence of messages as in the pre-
failure execution
→ Once the recovery is complete, both processes will be consistent
with the state of 𝑃0 that includes the receipt of message 𝑚7 from 𝑃1.
15
CS8603 DISTRIBUTED SYSTEMS UNIT 4
OPTIMISTIC LOGGING
o Processes log determinants asynchronously to the stable storage
o Optimistically assume that logging will be complete before a failure
occurs
o Do not implement the always-no-orphans condition
o To perform rollbacks correctly, optimistic logging protocols track causal
dependencies during failure free execution
o Optimistic logging protocols require a non-trivial garbage collection
scheme
o Pessimistic protocols need only keep the most recent checkpoint of each
process, whereas optimistic protocols may need to keep multiple
checkpoints for each process.
Example:
CAUSAL LOGGING
o Combines the advantages of both pessimistic and optimistic logging at
the expense of a more complex recovery protocol.
o Like optimistic logging, it does not require synchronous access to the
stable storage except during output commit.
16
CS8603 DISTRIBUTED SYSTEMS UNIT 4
Example:
→ Messages m5 and m6 are likely to be lost on the failures of P1
and P2 at the indicated instants.
→ Process P0 at state X will have logged the determinants of the
nondeterministic events that causally precede its state
according to Lamport’s happened-before relation.
→ These events consist of the delivery of messages m0, m1, m2,
m3, and m4. The determinant of each of these non-
deterministic events is either logged on the stable storage or
is available in the volatile log of process P0. The determinant
of each of these events contains the order in which its
original receiver delivered the corresponding message.
→ The message sender, as in sender-based message logging,
logs the message content. Thus, process P0 will be able to
“guide” the recovery of P1 and P2 since it knows the order in
which P1 should replay messages m1 and m3 to reach the
state from which P1 sent message m4.
17
CS8603 DISTRIBUTED SYSTEMS UNIT 4
18
CS8603 DISTRIBUTED SYSTEMS UNIT 4
19
CS8603 DISTRIBUTED SYSTEMS UNIT 4
20
CS8603 DISTRIBUTED SYSTEMS UNIT 4
o Asynchronous checkpointing
o After executing an event, the triplet is recorded without any
synchronization with other processes.
o Local checkpoint consist of set of records, first are stored in volatile log,
then moved to stable log.
21
CS8603 DISTRIBUTED SYSTEMS UNIT 4
o Notations:
22
CS8603 DISTRIBUTED SYSTEMS UNIT 4
23
CS8603 DISTRIBUTED SYSTEMS UNIT 4
o Example:
24
CS8603 DISTRIBUTED SYSTEMS UNIT 4
Introduction
Assumptions
o Failure models
25
CS8603 DISTRIBUTED SYSTEMS UNIT 4
Problem Specifications
26
CS8603 DISTRIBUTED SYSTEMS UNIT 4
Validity: If all the non-faulty processes have the same initial value,
then the agreed upon value by all the non-faulty processes must be
that same value.
Termination: Each non-faulty process must eventually decide on a
value.
Validity: If process i is non-faulty and its initial value is vi, then all
non-faulty processes agree on vi as the ith element of the array A. If
process j is faulty, then the non-faulty processes can agree on any
value for A[j].
OVERVIEW OF RESULTS
27
CS8603 DISTRIBUTED SYSTEMS UNIT 4
28
CS8603 DISTRIBUTED SYSTEMS UNIT 4
Algorithm
(global constants)
integer: f ; // maximum number of crash failures tolerated
(local variables)
integer: x ←− local value;
(1) Process Pi (1 ≤ i ≤ n) executes the Consensus algorithm for up to
f crash failures:
(1a) for round from 1 to f + 1 do
(1b) if the current value of x has not been broadcast then
(1c) broadcast(x);
(1d) yj ←− value (if any) received from process j in this round;
(1e) x ←− min(x, yj);
(1f) output x as the consensus value.
29
CS8603 DISTRIBUTED SYSTEMS UNIT 4
30
CS8603 DISTRIBUTED SYSTEMS UNIT 4
31
CS8603 DISTRIBUTED SYSTEMS UNIT 4
32
CS8603 DISTRIBUTED SYSTEMS UNIT 4
33
CS8603 DISTRIBUTED SYSTEMS UNIT 4
34
CS8603 DISTRIBUTED SYSTEMS UNIT 4
35
CS8603 DISTRIBUTED SYSTEMS UNIT 4
36