Transactions and Recovery Flashcards
What does ACID stand for?
<ul> <li>Atomicity</li> <li>Consistency</li> <li>Isolation</li> <li>Durability</li> </ul>
Describe Atomicity
Either all of the operations of a transaction are reflected in the database or none of them are
Describe Consistency
Preserves the consistency of the database by executing transactions in isolation
Describe Isolation
Even with concurrently executing transactions, it appears to each transaction that no other transaction was active at the same time
Describe Durability
Once changes have been made they are made permenantly (will persist after failure)
Who is the responsible party for atomicity of transactions?
Database
Who is the responsible party for consistency of transactions?
Application
Who is the responsible party for isolation of transactions?
Database
Who is the responsible party for durability of transactions?
Database
What are the five states a transaction can be in?
<ul> <li>Active</li> <li>Partially committed</li> <li>Failed</li> <li>Aborted</li> <li>Committed</li> </ul>
Describe the active state
The initial state, transaction stays in this state while it is executing
When is a transaction in a partially committed state?
After the final statement in the application logic has been executed
When is a transaction in a failed state?
After the discovery that normal execution cannot proceed
Describe the aborted state for a transaction
After the transaction has been rolled back, the database is restored to its prior state
What are the two options after a transaction has been aborted?
<ul>
<li>Restart the transaction</li>
<li>Kill the transaction</li>
</ul>
When is a transaction in the committed state?
After succesful completion and permenant storage of the change
What state guarantees durability?
Committed
What state guarantees isolation?
Active
What state guarantees atomicity?
Aborted
What does a schedule for transactions contain?
The order in which instructions of transactions should be executed with all instructions, preserving the order in which the instructions appear in each transaction
Describe a serial schedule
Transactions are run serially to completion
For a set of n transactions, how many different serial schedules are there?
n!
What is a benefit of serial schedules?
All serial schedules guarantee consistency
What are the operations that must be considered when trying to make equivalent non serial schedules?
Read and write operations
When is it important for the order of two transactions with I, J read write operations to be considered properly?
When I and J refer to the same data item
What is the condition for two schedules to be conflict equivalent?
<ul>
<li>One can be transformed into the other by a series of swaps of non-conflicting adjacent instructions</li>
</ul>
What does it mean for a schedule to be conflict serialisable?
<ul>
<li>If it is conflict equivalent to some serial schedule, meaning it's a correct schedule</li>
</ul>
When should a vertex be drawn between edges Ti and Tj in a directed precedence graph?
<ul>
<li>Ti executes write before Tj executes read</li>
<li>Ti executes read before Tj executes write</li>
<li>Ti executes write before Tj executes write</li>
</ul>
What does it mean for an edge to be between Ti and Tj in a directed precedence graph?
Ti must be executed before Tj in any serial schedule S’ equivalent to S
What property must exist in a precedence graph for a schedule to be conflict serialisable?
Graph must be ACYLIC
What are the two lock based protocols that are used to guarantee isolation?
<ul>
<li>Two phase protocol</li>
<li>Tree protocol</li>
</ul>
What is a lock and how is it related to when you can access an item?
Mechanism to control concurrent access to a data item, must acquire the item’s lock before accessing the item itself
What are the two modes that data can be locked in?
<ul>
<li>Exclusive(x)</li>
<li>Shared(s)</li>
</ul>
Describe the exclusive(x) mode
Data can be both read as well as written
Describe the shared(s) mode
Data item can only be read
Who is a lock request made to?
The concurrency control manager
What are the only two combinations of locks that are compatible together?
Two shared locks
What is a locking protocol?
A set of rules followed by all transactions while requesting and releasing locks