Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 14

Presented By:

Shweta Kushwaha(2k08it077)
Smriti Srivastava(2k08it078)
Topics which we are covered in our
presentation::

• What is concurrency control?


• Need of concurrency control
--Lost update problem
--Incorrect summary
• Concurrency control techniques
Lost Update Problem
 One user's update lost/overwritten by another user's
update.
• For eg. Let users are :A and B simultaneously access
an airline database wishing to reserve a number of
seats on a flight.

Where N=available
seats

If the execution of the two transactions were to take


place as shown in table one of the updates is lost
although both users read the number of seats, got the
bookings confirmed and wrote the updated number
back to the database. This is called the lost update
anomaly since the effects of one of the transactions
were lost.
Inconsistent Retrievals
• Consider two users A and B accessing a department database
simultaneously.
• The problem illustrated in the example is called the
inconsistent retrieval anomaly. During the execution of a
transaction therefore, changes made by another transaction
that has not yet committed, should not be visible since that
data may not be consistent
Classification Of
Techniques::
• 1. Locking data items to prevent multiple transactions
from accessing the items concurrently; a number of locking
protocols have been proposed.
• 2. Use of timestamps. A timestamp is a unique identifier
for each transaction, generated by the system.
• 3. Multiversion concurrency control protocols that use
multiple versions of a data item.
• 4. Optimistic Concurrency Control: based on the
concept of validation or certification of a transaction
after it executes its operations; these are sometimes called
optimistic protocols.
TYPES OF LOCKS:

• Binary locks
• Shared/exclusive locks
Binary Locks
• Binary lock can have two states :
• locked and unlocked (or 1 and 0, for
simplicity).
• A distinct lock is associated with each
database item X.
• If the value of the lock on X is 1, item X
cannot be accessed by a database operation
that requests the item.
• If the value of the lock on X is 0, the item
can be accessed when requested.
• We refer to the current value (or state) of
the lock associated with item X as LOCK(X).
8
Shared/Exclusive (or
Read/Write) Locks
• shared/exclusive or read/write
locks—there are three locking
operations:
– read_lock(X),
– write_lock(X), and
– unlock(X).

9
Locks

• A read-locked item is also called share-


locked, because other transactions are
allowed to read the item.
• A write-locked item is called exclusive-
locked, because a single transaction
exclusively holds the lock on the item.

10
Two-phase locking
( 2PL)
• A two-phase locking ( 2PL) scheme is a
locking scheme in which a transaction
cannot request a new lock after
releasing a lock. It has two phases:
– Growing Phase ( Locking Phase) - When
locks are acquired and none released.
– Shrinking Phase ( Unlocking Phase) - When
locks are released and none acquired.
Timestamping
• Timestamping:
– …is a concurrency control protocol.
– …ensures that transactions with smaller
(older) timestamps, get priority in the
event of conflict.
Optimistic concurrency control

In optimistic concurrency control, users do not


lock data when they read it. When a user updates
data, the system checks to see if another user
changed the data after it was read. If another
user updated the data, an error is raised. This is
called optimistic because it is mainly used in
environments where there is low contention for
data, and where the cost of occasionally rolling
back a transaction is lower than the cost of
locking data when read.
Thank you………..

You might also like