LATEST UPDATE (ALREADY GRADED A+)
Transaction
A logical unit of work that must be entirely completed or aborted
Atomicity
All operations of a transaction must be completed; if not the transaction is aborted
Consistency
Permanence of database's consistent state
Isolation
Data used during transaction cannot be used by second transaction until the first is completed
Durability
Ensures that once transactions are committed they cannot be undone or lost
Serializability
Ensures that the schedule for the concurrent execution of several transactions should yield consistent
results
Transaction Log
Keeps track of all transactions that update the database
DBMS uses the information stored in a log for (a):
- Recovery requirement triggered by a ROLLBACK statement
- Program's abnormal termination
- System failure
Concurrency Control
Coordination of the simultaneous transactions execution in a multiuser database system
• Objective: ensures serializability of transactions in a multiuser database environment
Problems in Concurrency Control
Lost update, uncommitted data, inconsistent retrievals
Scheduler
Establishes the order in which the operations are executed within concurrent transactions
- Creates serialization schedule
, Locking methods
facilitate isolation of data items used in concurrently executing transactions
Lock
guarantees exclusive use of a data item to a current transaction
Pessimistic locking
use of locks based on the assumption that conflict between transactions is likely
Lock manager
responsible for assigning and policing the locks used by the transactions
Lock Granularity
- indicates level of lock use
- levels: database, table, page, row, or field (attribute)
Binary lock
A lock that has only two states: locked (1) and unlocked (0). If a data item is locked by a transaction, no
other transaction can use that data item.
Exclusive lock
Access is reserved for the transaction that locked the object
Shared lock
Concurrent transactions are granted read access on the basis of a common lock
Problems using locks
- resulting transaction schedule might not be serializable
- schedule might create deadlocks
Two-Phase Locking to Ensure Serializability
Defines how transactions acquire and relinquish locks
• Guarantees serializability but does not prevent deadlocks
Phases
Growing and Shrinking
Growing phase
transaction acquires all required locks without unlocking any data
Shrinking phase
transaction releases all locks and cannot obtain any new lock