Content deleted Content added
m Fixed an incorrect schedule reference in the table. (Table named J while the text called it G) |
m →Cascadeless: Typo fixing, replaced: a.k.a, → a.k.a. |
||
(29 intermediate revisions by 7 users not shown) | |||
Line 3:
{{more citations needed|date=November 2012}}
In the fields of [[database]]s and [[transaction processing]] (transaction management), a '''schedule''' (or '''history''') of a system is an abstract model to describe the order of [[Execution (computing)|
Schedules are fundamental concepts in database [[concurrency control]] theory. In practice, most general purpose database systems employ conflict-serializable and strict recoverable schedules.
==Notation==
Grid notation:
* '''Columns:''' The different transactions in the schedule.
* '''Rows:''' The time order of operations (a.k.a., actions).
Operations (a.k.a., actions):
* '''R(X):''' The corresponding transaction "reads" object X (i.e., it retrieves the data stored at X). This is done so that it can modify the data (e.g., X=X+4) during a "write" operation rather than merely overwrite it. When the schedule is represented as a list rather than a grid, the action is represented as <math>Ri(X)</math> where <math>i</math> is a number corresponding to a specific transaction.
* '''W(X):''' The corresponding transaction "writes" to object X (i.e., it modifies the data stored at X). When the schedule is represented as a list rather than a grid, the action is represented as <math>Wi(X) </math> where <math>i</math> is a number corresponding to a specific transaction.
* '''Com.:''' This represents a "commit" operation in which the corresponding transaction has successfully completed its preceding actions, and has made all its changes permanent in the database.
Alternatively, a schedule can be represented with a ''[[acyclic directed graph|directed acyclic graph]]'' (or DAG) in which there is an arc (i.e., [[directed edge]]) between each ''[[ordered pair]]'' of operations.
=== Example ===
The following is an example of a schedule:
{| class="wikitable"
Line 50 ⟶ 63:
|Com.
|}
In this example, the
The schedule D above can be represented as list in the following way:
D = R1(X) W1(X) Com1 R2(Y) W2(Y) Com2 R3(Z) W3(Z) Com3
== Duration and order of actions ==
Usually, for the purpose of reasoning about concurrency control in databases, an operation is modelled as ''[[Atomicity (database systems)|atomic]]'', occurring at a point in time, without duration. Real executed operations always have some duration.
Operations of transactions in a schedule can interleave (i.e., transactions can be executed [[Concurrency (computer science)|concurrently]]), but time orders between operations in each transaction must remain unchanged. The schedule is in ''[[partial order]]'' when the operations of transactions in a schedule interleave (i.e., when the schedule is conflict-serializable but not serial). The schedule is in ''[[partial order|total order]]'' when the operations of transactions in a schedule do not interleave (i.e., when the schedule is serial).
==Types of schedule==
Line 70 ⟶ 79:
===Serial===
Schedule D is an example of a serial schedule:
Line 118 ⟶ 127:
===Serializable===<!-- This section is linked from [[Concurrency control]] -->
A schedule
In schedule E, the order in which the actions of the transactions are executed is not the same as in D, but in the end, E gives the same result as D.
Line 156 ⟶ 165:
|Com.
|}
Serializability is used to keep the data in the data item in a consistent state
If any specific order between some transactions is requested by an application, then it is enforced independently of the underlying serializability mechanisms. These mechanisms are typically indifferent to any specific order, and generate some unpredictable [[partial order]] that is typically compatible with multiple serial orders of these transactions
====Conflicting actions====
Line 191 ⟶ 196:
Equivalently, two schedules are said to be conflict equivalent if and only if one can be transformed to another by swapping pairs of non-conflicting operations (whether adjacent or not) while maintaining the order of actions for each transaction.<ref name=":0" />
Equivalently, two schedules are said to be conflict equivalent if and only if one can be transformed to another by swapping pairs of non-conflicting adjacent operations with different transactions.<ref>{{Cite book |last=Garcia-Molina |first=Hector |title=Database systems: the complete book |last2=Ullman |first2=Jeffrey D. |last3=Widom |first3=Jennifer |date=2009 |publisher=Pearson/Prentice Hall |isbn=978-0-13-187325-4 |edition=2nd |series=Pearson international edition |___location=Upper Saddle River, NJ |pages=
====Conflict-serializable====
A schedule is said to be '''conflict-serializable''' when the schedule is conflict-equivalent to one or more serial schedules.
Equivalently, a schedule is conflict-serializable if and only if its [[precedence graph]] is acyclic when only committed transactions are considered. Note that if the graph is defined to also include uncommitted transactions, then cycles involving uncommitted transactions may occur without conflict serializability violation.
Line 224 ⟶ 229:
|Com.
|}
Conflict serializability can be enforced by restarting any transaction within the cycle in the precedence graph, or by implementing [[two-phase locking]], [[Timestamp-based concurrency control|timestamp ordering]], or [[Snapshot isolation#Workarounds|serializable snapshot isolation]].<ref name="
====View equivalence====
Line 236 ⟶ 235:
Two schedules S1 and S2 are said to be view-equivalent when the following conditions are satisfied:
# If the transaction <math>T_i</math> in S1 reads an initial value for object X, so does the same transaction <math>T_i</math> in S2.
# If the transaction <math>T_i</math>
# If the transaction <math>T_i</math> in S1
Additionally, two view-equivalent schedules must involve the same set of transactions such that each transaction has the same actions in the same order.
In the example below, the schedules S1 and S2 are view-equivalent, but
{| class="wikitable"
! colspan="2" |S1
! colspan="2" |S2
! colspan="2" |S3
|-
!
!
!T1
!T2
!T1
!T2
|-
|R(A)
Line 264 ⟶ 267:
|
|-
|R(B)<sup>'''(1)'''</sup>
|
|
Line 280 ⟶ 283:
|Com.
|
|R(B)<sup>'''(1)'''</sup>
|
|
|R(B)<sup>'''(1)'''</sup>
|-
|
Line 296 ⟶ 299:
|Com.
|
|R(B)<sup>'''(2)'''</sup>
|
|-
|
|R(B)<sup>'''(2)'''</sup>
|
|R(B)<sup>'''(2)'''</sup>
|W(B)<sup>'''(3)'''</sup>
|
|-
|
|W(B)<sup>'''(3)'''</sup>
|
|W(B)<sup>'''(3)'''</sup>
|Com.
|
Line 320 ⟶ 323:
|Com.
|}
The conditions for S3 to be view-equivalent to S1 and
# Failed the first condition of view equivalence because T1 read the initial value for B in S1 and S2, but T2 read the initial value for B in S3.
# Failed the second condition of view equivalence because T2 read the value written by T1 for B in S1 and S2, but T1 read the value written by T2 for B in S3.
# Failed the third condition of view equivalence because T2 did the final write for B in S1 and S2, but T1 did the final write for B in S3.
To quickly analyze whether two schedules are view-equivalent, write both schedules as a list with each action's subscript representing which view-equivalence condition they match. The schedules are view equivalent if and only if all the actions have the same subscript (or lack thereof) in both schedules:
Line 389 ⟶ 392:
Since determining whether a schedule is view-serializable is [[NP-complete]], view-serializability has little practical interest.{{citation needed|date=April 2015}}
===Recoverable===<!-- This section is linked from [[Concurrency control]] -->
Line 406 ⟶ 397:
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"
! colspan="2" |F
! colspan="2" |F2
! colspan="2" |J
|-
!
!
!T1
!T2
!T1
!T2
|-
|R(A)
Line 457 ⟶ 452:
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.
====Cascadeless====
'''Cascadeless schedules''' (a.k.a
The following examples are the same as the ones in the discussion on recoverable:
{| class="wikitable"
! colspan="2" |F
! colspan="2" |F2
|-
!
!
!T1
!T2
|-
|R(A)
Line 538 ⟶ 535:
====Strict====
A schedule is '''strict
Any strict schedule is cascade-less, but not the converse. Strictness allows efficient recovery of databases from failure.
== Serializability class relationships ==
The following expressions illustrate the hierarchical (containment) relationships between [[serializability]] and [[Serializability#Correctness - recoverability|recoverability]] classes:
* Serial
* Serial ⊂ strict ⊂ cascadeless (ACA) ⊂ recoverable ⊂ all schedules
Line 552 ⟶ 549:
[[File:Schedule-serializability.png|frame|none|Venn diagram for serializability and recoverability classes]]
==See also==
* [[
* [[Two-phase locking|Strong strict two-phase locking]] (SS2PL or Rigorousness).
* [[Snapshot isolation#Making Snapshot Isolation Serializable|Making snapshot isolation serializable]]<ref name="Cahill082"
* [[Global serializability]], where the ''Global serializability problem'' and its proposed solutions are described.
* [[Linearizability]], a more general concept in [[concurrent computing]].
Line 566 ⟶ 559:
==References==
{{Reflist}}
[[Category:Data management]]
Line 575 ⟶ 565:
[[Category:Transaction processing]]
[[Category:Distributed computing problems]]
[[Category:NP-complete problems]]
|