0% found this document useful (0 votes)
14 views25 pages

Transaction Management and Con Currency

Uploaded by

riotleeis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views25 pages

Transaction Management and Con Currency

Uploaded by

riotleeis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 25

Transaction Management and

Concurrency
Control
Learning Objectives

In this chapter, students will learn:


About database transactions and their properties
What concurrency control is and what role it plays in maintaining the database’s
integrity
What locking methods are and how they work
How database recovery management is used to maintain database integrity
Transaction

Logical unit of work that must be entirely completed or aborted


Consists of:
SELECT statement

Series of related UPDATE statements


Series of INSERT statements
Combination of SELECT, UPDATE, and INSERT statements
Transaction

Consistent database state: All data integrity constraints are satisfied


Must begin with the database in a known consistent state to ensure consistency
Formed by two or more database requests
Database requests: Equivalent of a single SQL statement in an application program
or transaction
Consists of a single SQL statement or a collection of
related SQL statements
Evaluating Transaction Results

Not all transactions update database


SQL code represents a transaction because it accesses a database
Improper or incomplete transactions can have devastating effect on database integrity
Users can define enforceable constraints based on business rules
Other integrity rules are automatically enforced by the
 DBMS
Transaction Management with SQL

SQL statements that provide transaction support


COMMIT

ROLLBACK

Transaction sequence must continue until:


COMMIT statement is reached
ROLLBACK statement is reached
End of program is reached
Program is abnormally terminated
Transaction Log
Keeps track of all transactions that update the database

DBMS uses the information stored in a log for:


Recovery requirement triggered by a ROLLBACK statement
A program’s abnormal termination
A 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
The Scheduler

Establishes the order in which the operations are executed within concurrent transactions
Interleaves the execution of database operations to ensure serializability and isolation
of transactions
Based on concurrent control algorithms to determine the appropriate order
Creates serialization schedule
Serializable schedule: Interleaved execution of transactions yields the same results as
the serial execution of the transactions
Concurrency Control with Locking Methods

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

Lock Granularity
Indicates the level of lock use
Levels of locking
Database-level lock
Table-level lock
Page-level lock
 Page or diskpage: Directly addressable section of a disk
Row-level lock
Field-level lock
Figure 10.4 - An Example of a TableLevel Lock
Figure 10.6 - An Example of a RowLevel Lock
Deadlocks
Occurs when two transactions wait indefinitely for each other to unlock data
Known as deadly embrace
Control techniques
Deadlock prevention
Deadlock detection
Deadlock avoidance
Choice of deadlock control method depends on database environment
Time Stamping
Assigns global, unique time stamp to each transaction
Produces explicit order in which transactions are submitted to DBMS

Properties
Uniqueness: Ensures no equal time stamp values exist
Monotonicity: Ensures time stamp values always increases
Concurrency Control with Optimistic Methods

Optimistic approach: Based on the assumption that the majority of database


operations do not conflict
Does not require locking or time stamping techniques
Transaction is executed without restrictions until it is committed

You might also like