Concurrency Control
Concurrency Control
Concurrency Control
Figure 9.2
Transaction Properties
• Atomicity - undividable
• Requires that all operations (SQL requests) of a transaction be completed. if
not, the transaction is aborted.
• Consistency
• Indicates the permanence of the database’s consistent state.
• A transaction takes a database from one consistent state to another
consistent state.
• When a transaction is completed, the database must be in a consistent state;
if any of the transaction parts violates an integrity constraint, the entire
transaction is aborted.
Transaction Properties
• Isolation
• Data used during execution of a transaction cannot be used by
second transaction until first one is completed (useful in multi-user
environment)
• Durability
• ensures that once transaction changes are done (committed), they cannot be
undone or lost, even in the event of a system failure.
Transaction Properties
• Serializability– serial order (concurrency)
• Ensures that concurrent execution of several transactions yields consistent
results
Transaction Management with SQL
• ANSI has defined standards that govern SQL database transactions
• Transaction support is provided by two SQL statements: COMMIT and
ROLLBACK
Transaction Management with SQL
• ANSI standards require that, when a transaction sequence is initiated
by a user or an application program, it must continue through all
succeeding SQL statements until one of four events occurs
• COMMIT statement is reached
• ROLLBACK statement is reached
• End of program is reached
• Program is abnormally terminated
The Transaction Log
• Transaction log stores a record for the beginning of transaction
• For each transaction component (SQL statement):
• Type of operation being performed (update, delete, insert)
• Names of objects affected by transaction
• “Before” and “after” values for updated fields
• Pointers to previous and next transaction log entries for the same transaction
The Transaction Log
• Transaction log stores an ending (COMMIT) of the transaction
• Transaction log is Used for recovery from rollback, abnormal
termination, system failure (such as, disk crash).
The Transaction Log