5-Transaction Processing
5-Transaction Processing
Systems
M. Tamer Özsu
Patrick Valduriez
Begin_transaction
…
Read
Read
…
Write
Read
…
Commit
◼ Read set (RS)
❑ The set of data items that are read by a transaction
◼ Write set (WS)
❑ The set of data items whose values are changed by this transaction
◼ Base set (BS)
❑ RS and WS
ATOMICITY
❑ all or nothing
CONSISTENCY
❑ no violation of integrity constraints
ISOLATION
❑ concurrent changes invisible serializable
DURABILITY
❑ committed updates persist
13
Example of Serialization Conflict (*)
Graph S: … p1,i, …, p2,j, ...
T2 T4 S is serializable in order
* T1 T2 T3 T4 T5 T6 T7
T1 T5 T6 T7
T3
S is not serializable due
T2 T4
to cycle T2 T6 T7 T2
T1 T5 T6 T7
T3
14
Serializability in Distributed DBMS
◼ Pessimistic Algorithms
❑ Locking-based Algorithms
◼ Centralized (primary site) 2PL (Two-Phase
Locking)
◼ Distributed 2PL
❑ Timestamp-based Algorithms
◼ Basic TO (Timestamp Ordering)
◼ Conservative TO
❑ Multiversion Concurrency Control
◼ Optimistic Algorithms
time
Ti Tj
Local WFG
Global WFG
◼ Pessimistic Algorithms
❑ Locking-based Algorithms
◼ Centralized (primary site) 2PL (Two-Phase
Locking)
◼ Distributed 2PL
❑ Timestamp-based Algorithms
◼ Basic TO (Timestamp Ordering)
◼ Conservative TO
❑ Multiversion Concurrency Control
◼ Optimistic Algorithms
◼ Pessimistic Algorithms
❑ Locking-based Algorithms
◼ Centralized (primary site) 2PL (Two-Phase
Locking)
◼ Distributed 2PL
❑ Timestamp-based Algorithms
◼ Basic TO (Timestamp Ordering)
◼ Conservative TO
❑ Multiversion Concurrency Control
◼ Optimistic Algorithms
xr
© 2020, M.T. Özsu & P. Valduriez 38
Concurrency Control Algorithms
◼ Pessimistic Algorithms
❑ Locking-based Algorithms
◼ Centralized (primary site) 2PL (Two-Phase
Locking)
◼ Distributed 2PL
❑ Timestamp-based Algorithms
◼ Basic TO (Timestamp Ordering)
◼ Conservative TO
❑ Multiversion Concurrency Control
◼ Optimistic Algorithms
Pessimistic execution
Optimistic execution
❑ Distributed Reliability
Problem:
How to maintain
atomicity
durability
properties of transactions
Coordinator Participant
COMMIT
◼ Timeout in READY
❑ Participant has voted to commit the
transaction but does not know the
global decision of the coordinator.
❑ The participant cannot unilaterally
reach a decision.
❑ Stay blocked until it can learn from
someone (either the coordinator or
some other participant) the ultimate
fate of the transaction
© 2020, M.T. Özsu & P. Valduriez 59
Site Failures - 2PC Recovery
◼ 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
◼ 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
❑ These states represent the
termination conditions, so, upon
recovery, the participant does not
need to take any special action.
◼ 3PC is non-blocking.
◼ A commit protocols is non-blocking iff
❑ it is synchronous (occurring) within one state transition, and
◼ 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.
◼ In the first round, the proposer suggests a value for the variable and
acceptors send their responses (accept/not accept).
◼ If the proposer gets accepts from a majority of the acceptors, then it
determines that particular value to be the value of the variable and
notifies the acceptors who now record that value the final one.
◼ A learner can, at any point, ask an acceptor what the value of the
variable is and learn the latest value.
◼ Proposer/leader fails
❑ Choose a new leader and start a new ballot