5 Transaction Processing
5 Transaction Processing
Systems
M. Tamer Özsu
Patrick Valduriez
ATOMICITY
all or nothing
CONSISTENCY
no violation of integrity constraints
ISOLATION
concurrent changes invisible serializable
DURABILITY
committed updates persist
H’1, H’2 are individually serializable (in fact serial), but the
two transactions are not globally serializable.
Pessimistic
Two-Phase Locking-based (2PL)
Centralized (primary site) 2PL
Primary copy 2PL
Distributed 2PL
Timestamp Ordering (TO)
Basic TO
Multiversion TO
Conservative TO
Optimistic
Locking-based
Timestamp ordering-based
Tham khảo :
Ti Tj
Local WFG
Global WFG
Check if first 2
Conditions hold
Positive Yes
Any ?
neg? Update event clock:
No max(own,coord TM)
If global commit:
1) Persist 𝑇𝑖 updates
2) Update event clock
© 2020, M.T. Özsu & P. Valduriez 42
Outline
Distributed Transaction Processing
Distributed Reliability
Problem:
How to maintain
atomicity
durability
properties of transactions
Transaction failures
Transaction aborts (unilaterally or due to deadlock)
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
Media failures
Failure of secondary storage devices → stored data is lost
Head crash/controller failure
Communication failures
Lost/undeliverable messages
Network partitioning
© 2020, M.T. Özsu & P. Valduriez 45
Distributed Reliability Protocols
Commit protocols
How to execute commit command for distributed transactions.
Issue: how to ensure atomicity and durability?
Termination protocols
If 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.
Recovery protocols
When a failure occurs, how do the sites where the failure occurred deal
with it.
Independent: a failed site can determine the outcome of a transaction
without having to obtain remote information.
Independent recovery non-blocking termination
Coordinator Participant
COMMIT
Fig. 5.10
Fig. 5.12
C: Coordinator, P: Participant
© 2020, M.T. Özsu & P. Valduriez 49
2PC Protocol Actions
centralized 2PC
Fig. 5.11
To improve performance by
1) Reduce the number of messages between coordinator &
participants
2) Reduce the number of time logs are written
Presumed Abort 2PC
Participant polls coordinator about transaction’s outcome
No information → abort the transaction
Presumed Commit 2PC
Participant polls coordinator about transaction’s outcome
No information → assume transaction is committed
Not an exact dual of presumed abort 2PC
Coordinator Timeouts
Timeout in WAIT
Cannot unilaterally commit
Can unilaterally abort
Timeout in ABORT or COMMIT
Stay blocked and wait for the acks
Participant
Participant Timeouts
Timeout in INITIAL
Coordinator must have failed
in INITIAL state
Unilaterally abort
Timeout in READY
Stay blocked,
Coordinator
Failure in INITIAL
Start the commit process upon
recovery
Failure in WAIT
Restart the commit process upon
recovery
Failure in ABORT or COMMIT
Nothing special if all the acks have
been received
Otherwise the termination protocol is
involved
Participant
Failure in INITIAL
Unilaterally abort upon recovery
Failure in READY
The coordinator has been
informed about the local decision
Treat as timeout in READY state
and invoke the termination
protocol
Failure in ABORT or COMMIT
Nothing special needs to be done
Blocking
Ready implies that the participant waits for the coordinator
If coordinator fails, site is blocked until recovery
Blocking reduces availability
Independent recovery is not possible
However, it is known that:
Independent recovery protocols exist only for single site failures;
no independent recovery protocol exists which is resilient to
multiple-site failures.
So we search for these protocols – 3PC
3PC is non-blocking.
A commit protocols is non-blocking iff
it is synchronous within one state transition, and
its state transition diagram contains
no state which is “adjacent” to both a commit and an abort state,
and
no non-committable state which is “adjacent” to a commit state
Adjacent: possible to go from one stat to another with a
single state transition
Committable: all sites have voted to commit a
transaction
e.g.: COMMIT state
Coordinator Participant
3PC Protocol Actions
Simple partitioning
Only two partitions
Multiple partitioning
More than two partitions
Formal bounds:
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.
Ignore and
Wait
if all are Ack (not with bal’,val’)
then val ← proposer wants &
nbal ← bal
No
else val ← val’ & nbal ← bal nbal = ack.bal? Ignore
Yes
Record
accepted(nbal,val)