Introduction To Transaction Processing
Introduction To Transaction Processing
Processing
DBMS
Typical OLTP Environments
• occurs intermittently
• recovery time depends on the nature of
failure
Types of Failures
Bank 1 Bank 2
e = 2
3: (Acct.165) bal -=m2500
t t i
s a
s h e
c ra
Bank 1 a n k2 Bank 2
B
Bank 1 Bank 2
A unit of work
with respect to
concurrency and recovery.
What is a Transaction?
A sequence of operations
including database operations
that is atomic with respect to
concurrency and recovery.
What is a Transaction?
A.bal -= amount;
B.bal += amount;
A.bal -= amount;
CRASH
…
Rollback
…
RECOVERY
A.bal += amount;
Consistency
Consider the case of funds transfer from account A to account B.
A.bal -= amount;
B.bal += amount;
B.bal += amount;
A.bal -= amount (FAILS!! A’s balance is 0)
Rollback
B.bal -= amount;
Isolation
Consider the case of funds transfer from account A to account B.
Transaction T1:
A.bal -= amount; (Let A’s balance become 0 after this…)
B.bal += amount;
Transaction T2:
A.bal -= amount2;
Transaction T1:
A.bal -= amount;
B.bal += amount;
Commit
Partially
Committed
Committed
Active
Failed Aborted
ACD using Shadow Copy
DB
Copy of
DB DB
DB’
ACD Using Shadow Copy
T1: Read(Q)
T2: Write(Q)
T1: Write(Q)
T3: Write(Q)
View Serializability
• Every conflict serializable schedule is also
view serializable; however some view
serializable schedules are not conflict
serializable
• Example in previous slide
• A schedule that is view serializable but not
conflict serializable is characterized by
blind writes.
Recovery
• So far study of schedules that are acceptable from
the viewpoint of consistency of database-
assuming no transaction failures.
• If transaction T fails- undo the effect of the
transaction to ensure atomicity.
• Also, it is necessary to abort any other transaction
T1 that is dependent on T.
• To achieve the above two, restrictions on the type
of schedules permitted has to be laid down.
Recoverable Schedules