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
- One can be transformed into the other by a series of swaps of non-conflicting adjacent instructions
- If it is conflict equivalent to some serial schedule, meaning it's a correct schedule
- Ti executes write before Tj executes read
- Ti executes read before Tj executes write
- Ti executes write before Tj executes write
- Two phase protocol
- Tree protocol
- Exclusive(x)
- Shared(s)
- Deadlock
- Starvation
- Growing phase
- Shrinking phase
- Data itself
- Consistency of data
- Restart the transaction
- Discard the transaction
- Transaction failure
- System crash
- Disk failure
- Deferred database modification
- Immediate database modification
- When the transaction is executing the original updates
- When recovery action is being taken
- Redo(Ti)
- Undo(Ti)
- All records are flushed to the disk
- Checkpoint record written to log
- Completed transactions removed from log
- Outputted to stable storage in the order they are created
- Transaction enters commit stage only when log record has been output to stable storage
- Before data in main memory is output to database, all relevant log records must go into stable storage