Professional Documents
Culture Documents
end.
n Nested transaction
The operations of a transaction may themselves be
transactions.
Begin_transaction Reservation
Begin_transaction Airline
end. {Airline}
Begin_transaction Hotel
end. {Hotel}
end. {Reservation}
Distributed DBMS Page10-12. 24 1998 M. Tamer zsu & Patrick Valduriez
n Have the same properties as their parents may
themselves have other nested transactions.
n I ntroduces concurrency control and recovery
concepts to within the transaction.
n Types
Closed nesting
u Subtransactions begin after their parents and finish before
them.
u Commitment of a subtransaction is conditional upon the
commitment of the parent (commitment through the root).
Open nesting
u Subtransactions can execute and commit independently.
u Compensation may be necessary.
Nested Transactions
Page 13
Distributed DBMS Page10-12. 25 1998 M. Tamer zsu & Patrick Valduriez
Workflows
n A collection of tasks organized to accomplish some
business process. [D. Georgakopoulos]
n Types
Human-oriented workflows
u I nvolve humans in performing the tasks.
u System support for collaboration and coordination; but no
system-wide consistency definition
System-oriented workflows
u Computation-intensive & specialized tasks that can be
executed by a computer
u System support for concurrency control and recovery,
automatic task execution, notification, etc.
Transactional workflows
u I n between the previous two; may involve humans, require
access to heterogeneous, autonomous and/or distributed
systems, and support selective use of ACI D properties
Distributed DBMS Page10-12. 26 1998 M. Tamer zsu & Patrick Valduriez
Workflow Example
T
1
T
2
T
3
T
4
T
5
Customer
Database
Customer
Database
Customer
Database
T
1
: Customer request
obtained
T
2
: Airline reservation
performed
T
3
: Hotel reservation
performed
T
4
: Auto reservation
performed
T
5
: Bill generated
Page 14
Distributed DBMS Page10-12. 27 1998 M. Tamer zsu & Patrick Valduriez
Transactions Provide
n Atomic and reliable execution in the presence
of failures
n Correct execution in the presence of multiple
user accesses
n Correct management of replicas (if they
support it)
Distributed DBMS Page10-12. 28 1998 M. Tamer zsu & Patrick Valduriez
Transaction Processing Issues
n Transaction structure (usually called
transaction model)
Flat (simple), nested
n I nternal database consistency
Semantic data control (integrity enforcement)
algorithms
n Reliability protocols
Atomicity & Durability
Local recovery protocols
Global commit protocols
Page 15
Distributed DBMS Page10-12. 29 1998 M. Tamer zsu & Patrick Valduriez
Transaction Processing Issues
n Concurrency control algorithms
How to synchronize concurrent transaction
executions (correctness criterion)
I ntra-transaction consistency, I solation
n Replica control protocols
How to control the mutual consistency of replicated
data
One copy equivalence and ROWA
Distributed DBMS Page10-12. 30 1998 M. Tamer zsu & Patrick Valduriez
Architecture Revisited
Scheduling/
Descheduling
Requests
Transaction Manager
(TM)
Distributed
Execution Monitor
With other
SCs
With other
TMs
Begin_transaction,
Read, Write,
Commit, Abort
To data
processor
Results
Scheduler
(SC)
Page 16
Distributed DBMS Page10-12. 31 1998 M. Tamer zsu & Patrick Valduriez
Centralized Transaction Execution
Begin_Transaction,
Read, Write, Abort, EOT
Results &
User Notifications
Scheduled
Operations
Results
Results
Read, Write,
Abort, EOT
User
Application
User
Application
Transaction
Manager
(TM)
Scheduler
(SC)
Recovery
Manager
(RM)
Distributed DBMS Page10-12. 32 1998 M. Tamer zsu & Patrick Valduriez
Distributed Transaction Execution
Begin_transaction,
Read, Write, EOT,
Abort
User application
Results &
User notifications
Read, Write,
EOT, Abort
TM
SC
RM
SC
RM
TM
Local
Recovery
Protocol
Distributed
Concurrency Control
Protocol
Replica Control
Protocol
Distributed
Transaction Execution
Model
Page 17
Distributed DBMS Page10-12. 33 1998 M. Tamer zsu & Patrick Valduriez
Concurrency Control
n The problem of synchronizing concurrent
transactions such that the consistency of the
database is maintained while, at the same
time, maximum degree of concurrency is
achieved.
n Anomalies:
Lost updates
u The effects of some transactions are not reflected on
the database.
I nconsistent retrievals
u A transaction, if it reads the same data item more than
once, should always read the same value.
Distributed DBMS Page10-12. 34 1998 M. Tamer zsu & Patrick Valduriez
Execution Schedule (or History)
n An order in which the operations of a set of
transactions are executed.
n A schedule (history) can be defined as a partial
order over the operations of a set of transactions.
H
1
={W
2
(x),R
1
(x), R
3
(x),W
1
(x),C
1
,W
2
(y),R
3
(y),R
2
(z),C
2
,R
3
(z),C
3
}
T
1
: Read(x) T
2
: Write(x) T
3
: Read(x)
Write(x) Write(y) Read(y)
Commit Read(z) Read(z)
Commit Commit
Page 18
Distributed DBMS Page10-12. 35 1998 M. Tamer zsu & Patrick Valduriez
A complete schedule SC(T) over a set of
transactions T={T
1
, , T
n
}is a partial order
SC(T)={
T
, <
T
}where
T
=
i
i
, for i =1, 2, , n
<
T
i
<
i
, for i =1, 2, , n
For any two conflicting operations O
ij
, O
kl
T
,
either O
ij
<
T
O
kl
or O
kl
<
T
O
ij
Formalization of Schedule
Distributed DBMS Page10-12. 36 1998 M. Tamer zsu & Patrick Valduriez
Given three transactions
T
1
: Read(x) T
2
: Write(x) T
3
: Read(x)
Write(x) Write(y) Read(y)
Commit Read(z) Read(z)
Commit Commit
A possible complete schedule is given as the DAG
Complete Schedule Example
C
1
R
3
(x) R
1
(x) W
2
(x)
W
1
(x) W
2
(y) R
3
(y)
R
3
(z) R
2
(z)
C
2
C
3
Page 19
Distributed DBMS Page10-12. 37 1998 M. Tamer zsu & Patrick Valduriez
A schedule is a prefix of a complete schedule
such that only some of the operations and only
some of the ordering relationships are included.
T
1
: Read(x) T
2
:Write(x) T
3
: Read(x)
Write(x) Write(y) Read(y)
Commit Read(z) Read(z)
Commit Commit
Schedule Definition
R
1
(x) 1
C
1
R
3
(x) R
1
(x) R
3
(x) W
2
(x) W
2
(x)
W
1
(x) W
2
(y) W
2
(y) R
3
(y) R
3
(y)
R
3
(z) R
3
(z) R
2
(z) R
2
(z)
C
2
C
3
Page 39
Distributed DBMS Page10-12. 77 1998 M. Tamer zsu & Patrick Valduriez
Reliability
The mean number of failures in time [0, t] can be
computed as
and the variance can be be computed as
Var[k] =E[k
2
] - (E[k])
2
=m(t)
Thus, reliability of a single component is
R(t) =e
-m(t)
and of a system consisting of n non-redundant
components as
Fault-Tolerance Measures
E [k] =
k =0
k
k!
e
-m(t )
[m(t )]
k
= m(t )
R
sys
(t) =
i =1
n
R
i
(t)
Distributed DBMS Page10-12. 78 1998 M. Tamer zsu & Patrick Valduriez
Availability
A(t) =Pr{system is operational at time t}
Assume
u Poisson failures with rate
u Repair time is exponentially distributed with mean 1/
Then, steady-state availability
Fault-Tolerance Measures
A = lim A(t) =
t
+
Page 40
Distributed DBMS Page10-12. 79 1998 M. Tamer zsu & Patrick Valduriez
MTBF
Mean time between failures
MTBF =
0
R(t)dt
MTTR
Mean time to repair
Availability
MTBF
MTBF +MTTR
Fault-Tolerance Measures
Distributed DBMS Page10-12. 80 1998 M. Tamer zsu & Patrick Valduriez
S. Mourad and D. Andrews, The Reliability of the I BM/XA
Operating System, Proc. 15th Annual I nt. Symp. on FTCS, 1985.
Sources of Failure
SLAC Data (1985)
Operations
57%
Software
13%
Hardware
13%
Environment
17%
Page 41
Distributed DBMS Page10-12. 81 1998 M. Tamer zsu & Patrick Valduriez
Survey on Computer Security, J apan I nfo. Dev. Corp.,1986.
Sources of Failure
J apanese Data (1986)
Comm.
Lines
12%
Application
SW
25%
Operations
10%
Vendor
42%
Environment
11%
Distributed DBMS Page10-12. 82 1998 M. Tamer zsu & Patrick Valduriez
D.A. Yaeger. 5ESS Switch Performance Metrics. Proc. I nt.
Conf. on Communications, Volume 1, pp. 46-52, J une 1987.
Operations
18%
Unknown
6%
Hardware
32%
Software
44%
Sources of Failure
5ESS Switch (1987)
Page 42
Distributed DBMS Page10-12. 83 1998 M. Tamer zsu & Patrick Valduriez
J im Gray, Why Do Computers Stop and What can be
Done About I t?, Tandem Technical Report 85.7, 1985.
Operations
17%
Maintenance
25%
Environment
14% Software
26%
Hardware
18%
Sources of Failures
Tandem Data (1985)
Distributed DBMS Page10-12. 84 1998 M. Tamer zsu & Patrick Valduriez
Types of Failures
n Transaction failures
Transaction aborts (unilaterally or due to deadlock)
Avg. 3% of transactions abort abnormally
n System (site) failures
Failure of processor, main memory, power supply,
Main memory contents are lost, but secondary storage
contents are safe
Partial vs. total failure
n Media failures
Failure of secondary storage devices such that the
stored data is lost
Head crash/controller failure (?)
n Communication failures
Lost/undeliverable messages
Network partitioning
Page 43
Distributed DBMS Page10-12. 85 1998 M. Tamer zsu & Patrick Valduriez
Local Recovery Management
Architecture
n Volatile storage
Consists of the main memory of the computer system
(RAM).
n Stable storage
Resilient to failures and loses its contents only in the
presence of media failures (e.g., head crashes on disks).
I mplemented via a combination of hardware (non-volatile
storage) and software (stable-write, stable-read, clean-up)
components.
Secondary
storage
Stable
database
Read
Write
Write Read
Main memory
Local Recovery
Manager
Database Buffer
Manager
Fetch,
Flush
Database
buffers
(Volatile
database)
Distributed DBMS Page10-12. 86 1998 M. Tamer zsu & Patrick Valduriez
Update Strategies
n I n-place update
Each update causes a change in one or more data
values on pages in the database buffers
n Out-of-place update
Each update causes the new value(s) of data item(s)
to be stored separate from the old value(s)
Page 44
Distributed DBMS Page10-12. 87 1998 M. Tamer zsu & Patrick Valduriez
Database Log
Every action of a transaction must not only perform
the action, but must also write a log record to an
append-only file.
In-Place Update Recovery
Information
New
stable database
state
Database
Log
Update
Operation
Old
stable database
state
Distributed DBMS Page10-12. 88 1998 M. Tamer zsu & Patrick Valduriez
Logging
The log contains information used by the
recovery process to restore the consistency of a
system. This information may include
transaction identifier
type of operation (action)
items accessed by the transaction to perform the
action
old value (state) of item (before image)
new value (state) of item (after image)
Page 45
Distributed DBMS Page10-12. 89 1998 M. Tamer zsu & Patrick Valduriez
Why Logging?
Upon recovery:
all of T
1
's effects should be reflected in the database
(REDO if necessary due to a failure)
none of T
2
's effects should be reflected in the
database (UNDO if necessary)
0 t time
system
crash
T
1 Begin End
Begin T
2
Distributed DBMS Page10-12. 90 1998 M. Tamer zsu & Patrick Valduriez
n REDO'ing an action means performing it again.
n The REDO operation uses the log information
and performs the action that might have been
done before, or not done due to failures.
n The REDO operation generates the new image.
REDO Protocol
Database
Log
REDO
Old
stable database
state
New
stable database
state
Page 46
Distributed DBMS Page10-12. 91 1998 M. Tamer zsu & Patrick Valduriez
n UNDO'ing an action means to restore the
object to its before image.
n The UNDO operation uses the log information
and restores the old value of the object.
UNDO Protocol
New
stable database
state
Database
Log
UNDO
Old
stable database
state
Distributed DBMS Page10-12. 92 1998 M. Tamer zsu & Patrick Valduriez
When to Write Log Records
Into Stable Store
Assume a transaction T updates a page P
n Fortunate case
System writes P in stable database
System updates stable log for this update
SYSTEM FAI LURE OCCURS!... (before T commits)
We can recover (undo) by restoring P to its old state
by using the log
n Unfortunate case
System writes P in stable database
SYSTEM FAI LURE OCCURS!... (before stable log is
updated)
We cannot recover from this failure because there is
no log record to restore the old value.
n Solution: Write-Ahead Log (WAL) protocol
Page 47
Distributed DBMS Page10-12. 93 1998 M. Tamer zsu & Patrick Valduriez
WriteAhead Log Protocol
n Notice:
I f a system crashes before a transaction is committed,
then all the operations must be undone. Only need the
before images (undo portion of the log).
Once a transaction is committed, some of its actions
might have to be redone. Need the after images (redo
portion of the log).
n WAL protocol :
Before a stable database is updated, the undo portion of
the log should be written to the stable log
When a transaction commits, the redo portion of the log
must be written to stable log prior to the updating of
the stable database.
Distributed DBMS Page10-12. 94 1998 M. Tamer zsu & Patrick Valduriez
Logging Interface
Read
Write Write
Read
Main memory
Local Recovery
Manager
Database Buffer
Manager
Fetch,
Flush
Secondary
storage
Stable
log
Stable
database
Database
buffers
(Volatile
database)
Log
buffers
W
r
it
e
R
e
a
d
Page 48
Distributed DBMS Page10-12. 95 1998 M. Tamer zsu & Patrick Valduriez
n Shadowing
When an update occurs, don't change the old page, but
create a shadow page with the new values and write it
into the stable database.
Update the access paths so that subsequent accesses
are to the new shadow page.
The old page retained for recovery.
n Differential files
For each file F maintain
u a read only part FR
u a differential file consisting of insertions part DF+and
deletions part DF-
u Thus, F =(FR DF+) DF-
Updates treated as delete old value, insert new value
Out-of-Place Update
Recovery Information
Distributed DBMS Page10-12. 96 1998 M. Tamer zsu & Patrick Valduriez
Commands to consider:
begin_transaction
read
write
commit
abort
recover
I ndependent of execution
strategy for LRM
Execution of Commands
Page 49
Distributed DBMS Page10-12. 97 1998 M. Tamer zsu & Patrick Valduriez
n Dependent upon
Can the buffer manager decide to write some of
the buffer pages being accessed by a transaction
into stable storage or does it wait for LRM to
instruct it?
u fix/no-fix decision
Does the LRM force the buffer manager to write
certain buffer pages into stable database at the
end of a transaction's execution?
u flush/no-flush decision
n Possible execution strategies:
no-fix/no-flush
no-fix/flush
fix/no-flush
fix/flush
Execution Strategies
Distributed DBMS Page10-12. 98 1998 M. Tamer zsu & Patrick Valduriez
n Abort
Buffer manager may have written some of the updated
pages into stable database
LRM performs transaction undo (or partial undo)
n Commit
LRM writes an end_of_transaction record into the log.
n Recover
For those transactions that have both a
begin_transaction and an end_of_transaction record
in the log, a partial redo is initiated by LRM
For those transactions that only have a
begin_transaction in the log, a global undo is executed
by LRM
No-Fix/No-Flush
Page 50
Distributed DBMS Page10-12. 99 1998 M. Tamer zsu & Patrick Valduriez
n Abort
Buffer manager may have written some of the
updated pages into stable database
LRM performs transaction undo (or partial undo)
n Commit
LRM issues a flush command to the buffer
manager for all updated pages
LRM writes an end_of_transaction record into the
log.
n Recover
No need to perform redo
Perform global undo
No-Fix/Flush
Distributed DBMS Page10-12. 100 1998 M. Tamer zsu & Patrick Valduriez
n Abort
None of the updated pages have been written
into stable database
Release the fixed pages
n Commit
LRM writes an end_of_transaction record into
the log.
LRM sends an unfix command to the buffer
manager for all pages that were previously
fixed
n Recover
Perform partial redo
No need to perform global undo
Fix/No-Flush
Page 51
Distributed DBMS Page10-12. 101 1998 M. Tamer zsu & Patrick Valduriez
n Abort
None of the updated pages have been written into stable
database
Release the fixed pages
n Commit (the following have to be done atomically)
LRM issues a flush command to the buffer manager for
all updated pages
LRM sends an unfix command to the buffer manager
for all pages that were previously fixed
LRM writes an end_of_transaction record into the log.
n Recover
No need to do anything
Fix/Flush
Distributed DBMS Page10-12. 102 1998 M. Tamer zsu & Patrick Valduriez
n Simplifies the task of determining actions of
transactions that need to be undone or
redone when a failure occurs.
n A checkpoint record contains a list of active
transactions.
n Steps:
Write a begin_checkpoint record into the log
Collect the checkpoint dat into the stable storage
Write an end_checkpoint record into the log
Checkpoints
Page 52
Distributed DBMS Page10-12. 103 1998 M. Tamer zsu & Patrick Valduriez
Media Failures
Full Architecture
Read
Write Write
Read
Main memory
Local Recovery
Manager
Database Buffer
Manager
Fetch,
Flush
Archive
log
Archive
database
Secondary
storage
Stable
log
Stable
database
Database
buffers
(Volatile
database)
Log
buffers
Write Write
W
r
it
e
R
e
a
d
Distributed DBMS Page10-12. 104 1998 M. Tamer zsu & Patrick Valduriez
Distributed Reliability Protocols
n Commit protocols
How to execute commit command for distributed
transactions.
I ssue: how to ensure atomicity and durability?
n Termination protocols
I f a failure occurs, how can the remaining operational
sites deal with it.
Non-blocking : the occurrence of failures should not force
the sites to wait until the failure is repaired to terminate
the transaction.
n Recovery protocols
When a failure occurs, how do the sites where the failure
occurred deal with it.
I ndependent : a failed site can determine the outcome of a
transaction without having to obtain remote information.
n I ndependent recovery non-blocking termination
Page 53
Distributed DBMS Page10-12. 105 1998 M. Tamer zsu & Patrick Valduriez
Two-Phase Commit (2PC)
Phase 1 : The coordinator gets the participants
ready to write the results into the database
Phase 2 : Everybody writes the results into the
database
Coordinator :The process at the site where the
transaction originates and which controls the
execution
Participant :The process at the other sites that
participate in executing the transaction
Global Commit Rule:
The coordinator aborts a transaction if and only if at
least one participant votes to abort it.
The coordinator commits a transaction if and only if
all of the participants vote to commit it.
Distributed DBMS Page10-12. 106 1998 M. Tamer zsu & Patrick Valduriez
Centralized 2PC
ready? yes/no commit/abort? commited/aborted
Phase 1 Phase 2
C C C
P
P
P
P
P
P
P
P
Page 54
Distributed DBMS Page10-12. 107 1998 M. Tamer zsu & Patrick Valduriez
2PC Protocol Actions
Participant Coordinator
No
Yes
VOTE-COMMIT
Yes GLOBAL-ABORT
No
write abort
in log
Abort
Commit
ACK
ACK
INITIAL
write abort
in log
write ready
in log
write commit
in log
Type of
msg
WAIT
Ready to
Commit?
write commit
in log
Any No?
write abort
in log
ABORT COMMIT
COMMIT
ABORT
write
begin_commit
in log
write
end_of_transaction
in log
READY
INITIAL
PREPARE
VOTE-ABORT
VOTE-COMMIT
Distributed DBMS Page10-12. 108 1998 M. Tamer zsu & Patrick Valduriez
Linear 2PC
Prepare VC/VA
Phase 1
Phase 2
GC/GA
VC/VA VC/VA VC/VA
VC: Vote-Commit, VA: Vote-Abort, GC: Global-commit, GA: Global-abort
1 2 3 4 5 N
GC/GA GC/GA GC/GA GC/GA
Page 55
Distributed DBMS Page10-12. 109 1998 M. Tamer zsu & Patrick Valduriez
Distributed 2PC
prepare
vote-abort/
vote-commit
global-commit/
global-abort
decision made
independently
Phase 1
Coordinator Participants Participants
Distributed DBMS Page10-12. 110 1998 M. Tamer zsu & Patrick Valduriez
State Transitions in 2PC
INITIAL
WAIT
Commit command
Prepare
Vote-commit (all)
Global-commit
INITIAL
READY
Prepare
Vote-commit
Global-commit
Ack
Prepare
Vote-abort
Global-abort
Ack
Coordinator Participants
Vote-abort
Global-abort
ABORT COMMIT COMMIT ABORT
Page 56
Distributed DBMS Page10-12. 111 1998 M. Tamer zsu & Patrick Valduriez
Site Failures - 2PC Termination
n Timeout in I NI TI AL
Who cares
n Timeout in WAI T
Cannot unilaterally commit
Can unilaterally abort
n Timeout in ABORT or COMMI T
Stay blocked and wait for the acks
COORDINATOR
INITIAL
WAIT
Commit command
Prepare
Vote-commit
Global-commit
ABORT COMMIT
Vote-abort
Global-abort
Distributed DBMS Page10-12. 112 1998 M. Tamer zsu & Patrick Valduriez
n Timeout in I NI TI AL
Coordinator must have
failed in I NI TI AL state
Unilaterally abort
n Timeout in READY
Stay blocked
Site Failures - 2PC Termination
INITIAL
READY
Prepare
Vote-commit
Global-commit
Ack
Prepare
Vote-abort
Global-abort
Ack
ABORT COMMIT
PARTICIPANTS
Page 57
Distributed DBMS Page10-12. 113 1998 M. Tamer zsu & Patrick Valduriez
Site Failures - 2PC Recovery
n Failure in I NI TI AL
Start the commit process upon recovery
n Failure in WAI T
Restart the commit process upon
recovery
n Failure in ABORT or COMMI T
Nothing special if all the acks have
been received
Otherwise the termination protocol is
involved
COORDINATOR
INITIAL
WAIT
Commit command
Prepare
Vote-commit
Global-commit
ABORT COMMIT
Vote-abort
Global-abort
Distributed DBMS Page10-12. 114 1998 M. Tamer zsu & Patrick Valduriez
n Failure in I NI TI AL
Unilaterally abort upon recovery
n Failure in READY
The coordinator has been informed
about the local decision
Treat as timeout in READY state
and invoke the termination protocol
n Failure in ABORT or COMMI T
Nothing special needs to be done
INITIAL
READY
Prepare
Vote-commit
Global-commit
Ack
Prepare
Vote-abort
Global-abort
Ack
ABORT COMMIT
PARTICIPANTS
Site Failures - 2PC Recovery
Page 58
Distributed DBMS Page10-12. 115 1998 M. Tamer zsu & Patrick Valduriez
Arise due to non-atomicity of log and message send
actions
n Coordinator site fails after writing begin_commit
log and before sending prepare command
treat it as a failure in WAI T state; send prepare
command
n Participant site fails after writing ready record in
log but before vote-commit is sent
treat it as failure in READY state
alternatively, can send vote-commit upon recovery
n Participant site fails after writing abort record in
log but before vote-abort is sent
no need to do anything upon recovery
2PC Recovery Protocols
Additional Cases
Distributed DBMS Page10-12. 116 1998 M. Tamer zsu & Patrick Valduriez
n Coordinator site fails after logging its final
decision record but before sending its decision to
the participants
coordinator treats it as a failure in COMMI T or
ABORT state
participants treat it as timeout in the READY state
n Participant site fails after writing abort or
commit record in log but before
acknowledgement is sent
participant treats it as failure in COMMI T or ABORT
state
coordinator will handle it by timeout in COMMI T or
ABORT state
2PC Recovery Protocols
Additional Case
Page 59
Distributed DBMS Page10-12. 117 1998 M. Tamer zsu & Patrick Valduriez
Problem With 2PC
n Blocking
Ready implies that the participant waits for the
coordinator
I f coordinator fails, site is blocked until recovery
Blocking reduces availability
n I ndependent recovery is not possible
n However, it is known that:
I ndependent recovery protocols exist only for single
site failures; no independent recovery protocol exists
which is resilient to multiple-site failures.
n So we search for these protocols 3PC
Distributed DBMS Page10-12. 118 1998 M. Tamer zsu & Patrick Valduriez
n 3PC is non-blocking.
n A commit protocols is non-blocking iff
it is synchronous within one state
transition, and
its state transition diagram contains
u no state which is adjacent to both a commit
and an abort state, and
u no non-committable state which is adjacent
to a commit state
n Adjacent: possible to go from one stat to
another with a single state transition
n Committable: all sites have voted to
commit a transaction
e.g.: COMMI T state
Three-Phase Commit
Page 60
Distributed DBMS Page10-12. 119 1998 M. Tamer zsu & Patrick Valduriez
State Transitions in 3PC
INITIAL
WAIT
Commit command
Prepare
Vote-commit
Prepare-to-commit
Coordinator
Vote-abort
Global-abort
ABORT
COMMIT
PRE-
COMMIT
Ready-to-commit
Global commit
INITIAL
READY
Prepare
Vote-commit
Prepared-to-commit
Ready-to-commit
Prepare
Vote-abort
Global-abort
Ack
Participants
COMMIT
ABORT
PRE-
COMMIT
Global commit
Ack
Distributed DBMS Page10-12. 120 1998 M. Tamer zsu & Patrick Valduriez
Communication Structure
C
P
P
P
P
C
P
P
P
P
C
ready? yes/no
pre-commit/
pre-abort? commit/abort
Phase 1 Phase 2
P
P
P
P
C
yes/no ack
Phase 3
Page 61
Distributed DBMS Page10-12. 121 1998 M. Tamer zsu & Patrick Valduriez
n Timeout in I NI TI AL
Who cares
n Timeout in WAI T
Unilaterally abort
n Timeout in PRECOMMI T
Participants may not be in
PRE-COMMI T, but at least in
READY
Move all the participants to
PRECOMMI T state
Terminate by globally
committing
Site Failures
3PC Termination
INITIAL
WAIT
Commit command
Prepare
Vote-commit
Prepare-to-commit
Coordinator
Vote-abort
Global-abort
ABORT
COMMIT
PRE-
COMMIT
Ready-to-commit
Global commit
Distributed DBMS Page10-12. 122 1998 M. Tamer zsu & Patrick Valduriez
n Timeout in ABORT or
COMMI T
J ust ignore and treat the
transaction as completed
participants are either in
PRECOMMI T or READY
state and can follow their
termination protocols
Site Failures
3PC Termination
INITIAL
WAIT
Commit command
Prepare
Vote-commit
Prepare-to-commit
Coordinator
Vote-abort
Global-abort
ABORT
COMMIT
PRE-
COMMIT
Ready-to-commit
Global commit
Page 62
Distributed DBMS Page10-12. 123 1998 M. Tamer zsu & Patrick Valduriez
n Timeout in I NI TI AL
Coordinator must have
failed in I NI TI AL state
Unilaterally abort
n Timeout in READY
Voted to commit, but does
not know the coordinator's
decision
Elect a new coordinator
and terminate using a
special protocol
n Timeout in PRECOMMI T
Handle it the same as
timeout in READY state
INITIAL
READY
Prepare
Vote-commit
Prepared-to-commit
Ready-to-commit
Prepare
Vote-abort
Global-abort
Ack
Participants
COMMIT
ABORT
PRE-
COMMIT
Global commit
Ack
Site Failures
3PC Termination
Distributed DBMS Page10-12. 124 1998 M. Tamer zsu & Patrick Valduriez
New coordinator can be in one of four states: WAI T,
PRECOMMI T, COMMI T, ABORT
Coordinator sends its state to all of the participants asking
them to assume its state.
Participants back-up and reply with appriate messages,
except those in ABORT and COMMI T states. Those in these
states respond with Ack but stay in their states.
Coordinator guides the participants towards termination:
u I f the new coordinator is in the WAI T state, participants can be in
I NI TI AL, READY, ABORT or PRECOMMI T states. New
coordinator globally aborts the transaction.
u I f the new coordinator is in the PRECOMMI T state, the
participants can be in READY, PRECOMMI T or COMMI T states.
The new coordinator will globally commit the transaction.
u I f the new coordinator is in the ABORT or COMMI T states, at the
end of the first phase, the participants will have moved to that
state as well.
Termination Protocol Upon
Coordinator Election
Page 63
Distributed DBMS Page10-12. 125 1998 M. Tamer zsu & Patrick Valduriez
n Failure in I NI TI AL
start commit process upon
recovery
n Failure in WAI T
the participants may have
elected a new coordinator and
terminated the transaction
the new coordinator could be
in WAI T or ABORT states
transaction aborted
ask around for the fate of the
transaction
n Failure in PRECOMMI T
ask around for the fate of the
transaction
INITIAL
WAIT
Commit command
Prepare
Vote-commit
Prepare-to-commit
Coordinator
Vote-abort
Global-abort
ABORT
COMMIT
PRE-
COMMIT
Ready-to-commit
Global commit
Site Failures 3PC Recovery
Distributed DBMS Page10-12. 126 1998 M. Tamer zsu & Patrick Valduriez
n Failure in COMMI T or
ABORT
Nothing special if all the
acknowledgements have been
received; otherwise the
termination protocol is
involved
INITIAL
WAIT
Commit command
Prepare
Vote-commit
Prepare-to-commit
Coordinator
Vote-abort
Global-abort
ABORT
COMMIT
PRE-
COMMIT
Ready-to-commit
Global commit
Site Failures 3PC Recovery
Page 64
Distributed DBMS Page10-12. 127 1998 M. Tamer zsu & Patrick Valduriez
n Failure in I NI TI AL
unilaterally abort upon
recovery
n Failure in READY
the coordinator has been
informed about the local
decision
upon recovery, ask around
n Failure in PRECOMMI T
ask around to determine how
the other participants have
terminated the transaction
n Failure in COMMI T or
ABORT
no need to do anything
INITIAL
READY
Prepare
Vote-commit
Prepared-to-commit
Ready-to-commit
Prepare
Vote-abort
Global-abort
Ack
Participants
COMMIT
ABORT
PRE-
COMMIT
Global commit
Ack
Site Failures 3PC Recovery
Distributed DBMS Page10-12. 128 1998 M. Tamer zsu & Patrick Valduriez
n Simple partitioning
Only two partitions
n Multiple partitioning
More than two partitions
n Formal bounds (due to Skeen):
There exists no non-blocking protocol that is
resilient to a network partition if messages are
lost when partition occurs.
There exist non-blocking protocols which are
resilient to a single network partition if all
undeliverable messages are returned to sender.
There exists no non-blocking protocol which is
resilient to a multiple partition.
Network Partitioning
Page 65
Distributed DBMS Page10-12. 129 1998 M. Tamer zsu & Patrick Valduriez
Independent Recovery Protocols
for Network Partitioning
n No general solution possible
allow one group to terminate while the other is
blocked
improve availability
n How to determine which group to proceed?
The group with a majority
n How does a group know if it has majority?
centralized
u whichever partitions contains the central site should
terminate the transaction
voting-based (quorum)
u different for replicated vs non-replicated databases
Distributed DBMS Page10-12. 130 1998 M. Tamer zsu & Patrick Valduriez
n The network partitioning problem is
handled by the commit protocol.
n Every site is assigned a vote Vi.
n Total number of votes in the system V
n Abort quorum V
a
, commit quorum V
c
V
a
+V
c
>V where 0 V
a
, V
c
V
Before a transaction commits, it must obtain
a commit quorum V
c
Before a transaction aborts, it must obtain an
abort quorum V
a
Quorum Protocols for
Non-Replicated Databases
Page 66
Distributed DBMS Page10-12. 131 1998 M. Tamer zsu & Patrick Valduriez
State Transitions in
Quorum Protocols
INITIAL
WAIT
Commit command
Prepare
Vote-commit
Prepare-to-commit
Coordinator
Vote-abort
Prepare-to-abort
ABORT COMMIT
PRE-
COMMIT
Ready-to-commit
Global commit
INITIAL
READY
Prepare
Vote-commit
Prepare-to-commit
Ready-to-commit
Prepare
Vote-abort
Global-abort
Ack
Participants
COMMIT ABORT
PRE-
COMMIT
Global commit
Ack
PRE-
ABORT
Prepared-to-abortt
Ready-to-abort
PRE-
ABORT
Ready-to-abort
Global-abort
Distributed DBMS Page10-12. 132 1998 M. Tamer zsu & Patrick Valduriez
n Network partitioning is handled by the
replica control protocol.
n One implementation:
Assign a vote to each copy of a replicated data
item (say V
i
) such that
i
V
i
=V
Each operation has to obtain a read quorum (V
r
)
to read and a write quorum (V
w
) to write a data
item
Then the following rules have to be obeyed in
determining the quorums:
u V
r
+V
w
>V a data item is not read and written
by two transactions concurrently
u V
w
>V/2 two write operations from two
transactions cannot occur
concurrently on the same data item
Quorum Protocols for
Replicated Databases
Page 67
Distributed DBMS Page10-12. 133 1998 M. Tamer zsu & Patrick Valduriez
n Simple modification of the ROWA rule:
When the replica control protocol attempts to read
or write a data item, it first checks if a majority of
the sites are in the same partition as the site that
the protocol is running on (by checking its votes).
I f so, execute the ROWA rule within that
partition.
n Assumes that failures are clean which
means:
failures that change the network's topology are
detected by all sites instantaneously
each site has a view of the network consisting of
all the sites it can communicate with
Use for Network Partitioning
Distributed DBMS Page10-12. 134 1998 M. Tamer zsu & Patrick Valduriez
Open Problems
n Replication protocols
experimental validation
replication of computation and communication
n Transaction models
changing requirements
u cooperative sharing vs. competitive sharing
u interactive transactions
u longer duration
u complex operations on complex data
relaxed semantics
u non-serializable correctness criteria
Page 68
Distributed DBMS Page10-12. 135 1998 M. Tamer zsu & Patrick Valduriez
Transaction Model Design Space
Object complexity
Transaction
structure
flat closed
nesting
open
nesting
mixed
simple
data
ADT +
complex
objects
ADT
instances
active
objects