Database transaction schedule: Difference between revisions

Content deleted Content added
Types of schedule: explained the purpose of undoing all the actions
Unrecoverable: Improved explanation and made headings better organized.
Line 378:
===Recoverable===<!-- This section is linked from [[Concurrency control]] -->
 
In a '''recoverable schedule''', transactions only commit after all transactions whose changes they read have committed. A schedule becomes '''unrecoverable''' if a transaction <math>T_i</math> reads and relies on changes from another transaction <math>T_j</math>, and then <math>T_i</math> commits and <math>T_j</math> aborts.
{| class="wikitable"
|+F & F2
!F: T1
!F: T2
!F2: T1
!F2: T2
!G: T1
!G: T2
|-
|R(A)
|R(A)
|
Line 391 ⟶ 394:
|
|-
|W(A)
|W(A)
|
Line 396 ⟶ 401:
|
|-
|R(A)
|
|R(A)
Line 401 ⟶ 408:
|R(A)
|-
|W(A)
|
|W(A)
Line 410 ⟶ 419:
|Abort
|
|-
|
|Com.
|Abort
|}These schedules are recoverable. The schedule F is recoverable because T1 commits before T2, that makes the value read by T2 correct. Then T2 can commit itself. In the F2 schedule, if T1 aborted, T2 has to abort because the value of A it read is incorrect. In both cases, the database is left in a consistent state.
 
====Unrecoverable====
 
A schedule becomes '''unrecoverable''' if a transaction <math>T_i</math> reads and relies on changes from another transaction <math>T_j</math>, and then <math>T_i</math> commits and <math>T_j</math> aborts.
 
{| class="wikitable"
|+G
!T1
!T2
|-
|R(A)
|
|Com.
|-
|W(A)
|
|-
|R(A)
|-
|W(A)
|-
|Com.
|-
|Abort
|Abort
|
|-
|
|}
|}These schedules are recoverable. The schedule F is recoverable because T1 commits before T2, that makes the value read by T2 correct. Then T2 can commit itself. In the F2 schedule, if T1 aborted, T2 has to abort because the value of A it read is incorrect. In both cases, the database is left in a consistent state.
 
In this example,Transaction G is unrecoverable, because T2 readcommitted thebefore valueT1 ofdespite Apreviously reading the value written by T1, and committed. Because T1 later aborted, thereforeafter T2 committed, the value read by T2 is wrong,. butBecause sincea T2transaction committedcannot be rolled-back after it commits, thisthe schedule is unrecoverable.
 
====Cascadeless====