Professional Documents
Culture Documents
Flipped
Flipped
Group Members:
Name Roll No
Himani Vilas Bhirud 221081
Anjali Upendra More 221082
Shraddha Umesh Mulay 221083
Preeti Chandrakant Alegaonkar 221084
1.
Concurrency Control
2
Concurrency Execution :
3
What is Concurrency Control ?
4
Need of Concurrency Control :
5
Example
• Assume that two people who go to electronic kiosks at the same
time to buy a movie ticket for the same movie and the same show
time.
• However, there is only one seat left in for the movie show in that
particular theatre. Without concurrency control in DBMS, it is
possible that both moviegoers will end up purchasing a ticket.
However, concurrency control method does not allow this to
happen. Both moviegoers can still access information written in the
movie seating database. But concurrency control only provides a
ticket to the buyer who has completed the transaction process first.
6
Methods of Concurrency Control :
1. Locking Methods
2. Time-Stamp Methods
7
2.
Locking Methods of
Concurrency Control
8
Locking Methods of Concurrency Control
A lock is a variable, associated with the data item, which
controls the access of that data item.
9
Lock Granularity :
Lock granularity indicates the level of access to a database
defined by a lock manager.
Locking can take place at the following level :
1. Database level.
2. Table level.
3. Page level.
4. Row (Tuple) level.
5. Attributes (fields) level.
10
To be continued…
1. Database level: Only one transaction has access to the database.
2. Table level: Each table allows only one transaction to interact at a
time.
3. Page level: Number of rows locked across one or multiple tables.
4. Row(tuple) level: Each locked row allows one transaction to
interact with it at a time.
5. Attribute(field) level: Each locked attribute allows only one
transaction to interact with it at a time.
11
Lock Types:
The DBMS mainly uses following types of locking
techniques:
1. Binary Locking
2. Shared / Exclusive Locking
3. Two - Phase Locking (2PL)
12
Binary Locking: Shared/Exclusive Two-Phase
Locking : Locking (2PL):
Shared lock(s): Growing phase:
A binary lock can
have two states or Transaction locked In which a
values: locked and data item in shared transaction acquires
unlocked (or 1 and mode then allowed all the required
0, for simplicity). to read only. locks without
unlocking any data.
shrinking phase:
Operations: Exclusive lock(x):
In which a
1. Lock_item(X) Transaction locked
transaction releases
2.Unlock_item (X) data item in
all locks and cannot
exclusive mode then
obtain any new
allowed to read and
lock.
write both. 13
3.
Deadlock
14
What is Deadlock in DBMS?
Bridge
15
Lets see an example….
Transaction A = access data items X and Y
Transaction B = access data items Y and X
• Transaction-A has acquired lock on X and is waiting to acquire lock on Y.
• Transaction-B has acquired lock on Y and is waiting to acquire lock on X.
A B
Req
ues
t
Hold
Hold
q uest
X Re Y
Hold
Hold
u ire
q
X Ac Y
17
Deadlock Detection
• When a transaction waits indefinitely to obtain a lock, The database
management system should detect whether the transaction is
involved in a deadlock or not.
• Wait-for-graph
• In this method a graph is drawn based on the transaction and their
lock on the resource. If the graph created has a closed loop or a
cycle, then there is a deadlock. Wait for Lock(X)
T1 T2
1. Wait-Die Scheme
2. Wound Wait Scheme
19
4.
Time-Stamp Methods
for Concurrency control
20
Timestamps must have two properties
namely :
1. Uniqueness : The uniqueness property assures that
no equal timestamp values can exist.
2. Monotonicity : The monotonicity assures that
timestamp values always increase.
21
Example:
Suppose there are three transactions T1, T2, and T3.
22
Timestamp Ordering Protocol
23
• Suppose transaction Ti issues a read(X) operation:
• If TS(Ti) < W-timestamp(X)
Operation rejected.
• If TS(Ti) >= W-timestamp(X)
Operation executed.
• All data-item timestamps updated.
24
Timestamp Ordering is divided
into further fields :
25
Drawbacks of Time-stamp
• Each value stored in the database requires two
additional timestamp fields, one for the last time the
field (attribute) was read and one for the last update.
• processing
It increases the memory requirements and the
overhead of database.
26
Thank You!
27