Trans
Trans
CSC502
Transaction Processing
Transaction Processing
Outline
Basic Concept of Transaction
ACID Properties
Transaction State
Concurrent Executions
Serializability
Recoverability
Implementation of Isolation
Basic Concept of Transaction
1. read(A)
2. A := A – 50
3. write(A)
4. read(B)
5. B := B + 50
6. write(B)
Atomicity requirement
➢ If the transaction fails (due to software or hardware) after step 3 and
before step 6, money will be “lost” leading to an inconsistent database
state
1. read(A)
2. A := A – 50
3. write(A)
4. read(B)
5. B := B + 50
6. write(B)
Durability requirement
once the user has been notified that the transaction has completed
(i.e., the transfer of the $50 has taken place), the updates to the d
database by the transaction must persist even if there are software
or hardware failures.
Required Properties of a Transaction (Cont.)
Consistency requirement
➢ The sum of A and B is unchanged by the execution of the transaction
T1 T2
1. read(A)
2. A := A – 50
3. write(A)
read(A), read(B), print(A+B)
4. read(B)
5. B := B + 50
6. write(B
Isolation can be ensured trivially by running transactions serially. That is, one after
the other.
However, executing multiple transactions concurrently has significant benefits.
ACID Properties
➢ That is, for every pair of transactions Ti and Tj, it appears to Ti that either
Tj, finished execution before Ti started, or Tj started execution after Ti
finished.
Active – the initial state; the transaction stays in this state while it is
executing
1. Conflict serializability
2. View serializability
However, if li and lj refer to the same data item Q, then the order of
the two instructions may matter.
Since we are dealing only read and write instructions, so there are
four cases
1. li = read(Q), lj = read(Q).
2. li = read(Q), lj = write(Q).
3. li = write(Q), lj = read(Q).
4. li = write(Q), lj = write(Q).
Conflicting Instructions
Since we are dealing only read and write instructions, so
there are four cases
Schedule 3
read(A)
read(A)
write(A)
read(B) T1 T2
write(A)
read(B)
write(B)
write(B) read(B) of T2 executes before T1 executes
write(B). So edge from T2 to T1
write(Q)
3. The transaction (if any) that performs the final write(Q) operation in
schedule S must also perform the final write(Q) operation in
schedule S’.
Note that, view equivalence is also based purely on reads and writes
alone.
View Serializability (Cont.)
A schedule S is view serializable if it is view equivalent to a serial schedule.
Every conflict serializable schedule is also view serializable, but not vice
versa, i.e. every view serializable is not conflict serializable schedule.
Every view serializable schedule that is not conflict serializable has blind
writes.
Test for View Serializability
The precedence graph test for conflict serializability cannot be used
directly to test for view serializability.
➢ Extension to test for view serializability has cost exponential in the size
of the precedence graph.
If T8 should abort, T9 would have read (and possibly shown to the user) an
inconsistent database state. Hence, database must ensure that schedules
are recoverable.
Cascading Rollbacks
Cascading rollback – a single transaction failure leads to a series of
transaction rollbacks.
Consider the following schedule where none of the transactions has yet
committed (so the schedule is recoverable)
Testing a schedule for serializability after it has executed is a little too late!
➢ Tests for serializability help us understand why a concurrency control
protocol is correct