410 likes | 600 Views
Distributed Database Management Systems. Lecture 27. In the previous lecture. Defined Transaction Formally ACID Properties of a Transaction. In this Lecture. ACID Properties Types of Transaction Transaction in DDBS. Isolation and consistency are interrelated, one supports other
E N D
Distributed Database Management Systems Lecture 27
In the previous lecture • Defined Transaction Formally • ACID Properties of a Transaction
In this Lecture • ACID Properties • Types of Transaction • Transaction in DDBS
Isolation and consistency are interrelated, one supports other • Degree 3 provides full isolation • SQL-92 identified isolation levels based on following phenomena.
Dirty Read: A transaction reads the written value of another transaction before its commitment, like, --, W1(x), ----, R2(x), --- ,C1(or A1)-----, C2(or A2).
Non-repeatable or Fuzzy Read: Two reads of same data item by same Tr and a write by another Tr on the same data item --, R1(x), ----, W2(x), --- ,C2-----, R1(x)----
Phantom: T1 performs a read on a predicate, T2 inserts tuples that satisfy the predicate --, R1(P), ----, W2(yinP), --- ,C2(orA2)-----, C1(orA1)---
Isolation levels • Read Uncommitted: all three phenomena possible • Read Committed: fuzzy read, phantoms possible; DR not possible • Repeatable Read: Only phantoms possible • Anomaly Serializable: None of the phenomena possible
4- Durability: • Once committed, changes to DB are permanent.
Timing • on-line (short-life) vs batch (long-life) • Structure • flat (or simple) transactions • nested transactions.
Organization of read and write actions • two-step (all reads before any write) • Restricted (Read an item before write) • action model (Read/write on an item to be atomic.
Flat transaction • Consists of a sequence of primitive operations embraced between a begin and end markers. • Begin_transaction Reservation … end.
Nested transaction • The operations of a transaction may themselves be transactions. • Begin_transaction Reservation … Begin_transaction Airline … end {Airline} end {Reservation}
Nested Transactions • Have the same properties as their parents;may themselves have other nested transactions. • Introduces concurrency control and recovery concepts within the transaction.
Closed nesting • Sub transactions begin after their parents and finish before them • Commitment of a sub transaction is conditional upon the commitment of the parent (commitment through the root) • Open nesting • Sub transactions can execute and commit independently. • Compensation may be necessary.
Flat transaction model suits relatively small and simple environments • Certain environments need combination of open and nested models.
A candidate definition “ a collection of tasks organized to accomplish some business activity” • Different types of workflows.
Workflows generally involve long transactions, like a reservation transaction that may include Airline, Hotel, Auto reservations and bill generation.
Workflows exhibit open nesting semantics • So permits access to the results of sub-activity before the commitment of the major activity.
Some components are declared as vital, main activity aborts if a vital component aborts, otherwise it may commit even if a non-vital component aborts, like….
Compensating Transactions • Contingency Transactions.
Begin Transaction, Read Write, Commit, Abort Results Distributed Execution Monitor With other SCs With other TMs Transaction Manager With other Data processors Coordinates transactions exec Scheduler Sched/De-Sched requests
Distributed Concurrency Control Chapter 11
CC concerns synchronizing concurrent transactions maintaining consistency of the database and maximizing degree of concurrency.
Schedule or History An order in which the operations of a set of transactions are executed.
A schedule (history) can be defined as a partial order over the operations of a set of transactions.
S={W 2 (x),R 1 (x), R 3 (x),W 1 (x),C 1 ,W2(y), R 3 (y),R 2 (z),C 2 ,R 3 (z),C 3 }
A complete schedule S over a set of transactions T={T1, …, Tn} is a partial order • SCT(T, <T) where • T = Ui i, for i = 1, 2, …, n • <T U <i, for i = 1, 2, …, n • For any two conflicting operations Oij, Okl∈T, either Oij<T Oklor Okl<T Oij
1 = {R1(x), W1(x), C1} • 2 = {W2(x), W2(y), R2(z), C2} • 3 = {R3(x), R3(y), R3(z), C3} • = 1 U 2 U 3 ={R1(x), W1(x), C1, W2(x), W2(y), R2(z), C2, R3(x), R3(y), R3(z), C3}
R1(x) W2(x) R3(x) W1(x) W2(y) R3(y) C1 R2(z) R3(z) C2 C3 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.
Serial Schedule If all the transactions included in it execute one after another. A serial schedules always leaves the database in a consistent state.
They may end up with a different final state of DB each one of them being consistent • If we have three transactions, T1, T2, T3 then one serial schedule may be: T1 <S T3 <s T2 or T1 T3 T2
Interleaved Schedule A schedule is in which operations from different transactions are mixed with each other in execution.
Like S1 ={W2(x), R1(x), R3 (x), W1(x),C1, W2(y), R3(y), R2(z),C2,R3 (z), C3} is an interleaved schedule.