Transactions Flashcards
What are transactions
These are used for controlling operations on persistent shared information.
Transaction properties and definitions
Atomicity
Consistency
Independence
Durability
Atomicity
All or nothing. This state ensures automatic recovery of a system to its prior state in the event of failure
Consistency
Serialisability. This ensures transactions are scheduled to run without interference
Independence
Containment. This ensures all updates done by a transaction are visible to all to other transactions before it terminates
Durability
Persistence. All results produced by a successfully completed terminated transactions are not affected by subsequent failures
Transaction primatives
Begin transaction
End transaction
Abort
Begin transaction
Command indicating the start of a transaction
End transaction
This can have 2 outcomes
Normal termination: Normal ending where all changes made are saved and stored to disk
Abnormal termination: No results produced from transaction termination. This means failures occurred
Abort
Explicitly aborting transaction under control of program
Read lock
reading can be shared. A read lock is permitted provided object is not write locked
Write lock
Writing is exclusive so a write lock is permitted if there is no read or write lock on the object
Deadlocks
If a transactions response to a conflict is to wait for the lock, then there is a danger for deadlocking as it can lead to wait for cycles
2 Phase locking rules
(i) A transaction must obtain a lock on an object before using it;
(ii) growing phase: locks are acquired and acquired locks are not released;
(iii) shrinking phase: acquired locks are released and no new locks are acquired.
Lock point
A transaction at some point in time must hold all the locks on objects
it is using in its computation. This point is called the lock point