Lecture Slides available: PDF PowerPoint Concurrency using TransactionsContents
The goal in a `concurrent' DBMS is to allow multiple users to access the database simultaneously without interfering with each other. A problem with multiple users using the DBMS is that it may be possible for two users to try and change data in the database simultaneously. If this type of action is not carefully controlled, inconsistencies are possible. To control data access, we first need a concept to allow us to encapsulate database accesses. Such encapsulation is called a `Transaction'. Transactions
After work is performed in a transaction, two outcomes are possible:
Transaction SchedulesA transaction schedule is a tabular representation of how a set of transactions were executed over time. This is useful when examining problem scenarios. Within the diagrams various nomenclatures are used:
Consider transaction A, which loads in a bank account balance X (initially 20) and adds 10 pounds to it. Such a schedule would look like this:
Now consider that, at the same time as transaction A runs, transaction B runs. Transaction B gives all accounts a 10% increase. Will X be 32 or 33?
Whoops... X is 22! Depending on the interleaving, X can also be 32, 33, or 30. Lets classify erroneous scenarios. Lost Update scenario.
Transaction A's update is lost at t4, because Transaction B overwrites it. B missed A's update at t3 as it got the value of R at t2.
Uncommitted Dependency
Transaction A is allowed to READ (or WRITE) item R which has been updated by another transaction but not committed (and in this case ABORTed). Inconsistency
Serialisability
Precedence GraphIn order to know that a particular transaction schedule can be serialized, we can draw a precedence graph. This is a graph of nodes and vertices, where the nodes are the transaction names and the vertices are attribute collisions. The schedule is said to be serialised if and only if there are no cycles in the resulting diagram. Precedence Graph : MethodTo draw one;
Example 1Consider the following schedule:
Example 2Consider the following schedule:
|
|