“Overview of Concurrency control and recovery
in distributed database”
Presented by : Prashi Jain
Roll No. : MA/25022/18
What is concurrency control
 Concurrency control is the procedure in DBMS for managing simultaneous
operations without conflicting with each another.
 Concurrent access is quite easy if all users are just reading data. There is no way
they can interfere with one another.
 Though for any practical database, would have a mix of reading and WRITE
operations and hence the concurrency is a challenge.
Why use Concurrency method?
 To apply Isolation through mutual exclusion between conflicting transactions.
To resolve read-write and write-write conflict issues
To preserve database consistency through constantly preserving execution
obstructions
The system needs to control the interaction among the concurrent transactions.
This control is achieved using concurrent-control schemes.
Concurrency control helps to ensure serializability
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, 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.
Concurrency Control Protocols
In order to maintain the concurrent access of transactions, two
protocols are introduced :-
1- lock based protocol
2- time stamp based protocol
Lock based protocol
A lock is applied to avoid concurrency problem between two transaction in such a way that
the lock is applied on one transaction and other transaction can access it only when the lock
is released. The lock is applied on write or read operations.
These locks are broadly classified into:-
1- binary locks:- In binary lock data can either be locked or unlocked. It will have only
these two states.
2-Shared/exclusive locks:- data is said to be exclusively locked if for insert / update
/delete. When it is exclusively locked no other transaction can read or write the data.
When a data is read from the database, then its lock is shared i.e.; the data can be read by
other transaction too but it cannot be changed while retrieving the data.
Lock based protocols are of 4 types
 Simplistic Lock Protocol: - This protocol allows all the transaction to get the lock on the data
before insert / update /delete on it. After completing the transaction, it will unlock the data.
 Pre-claiming Protocol: - Pre-claiming lock protocol helps to evaluate operations and create a
list of required data items which are needed to initiate an execution process. In the situation
when all locks are granted, the transaction executes. After that, all locks release when all of its
operations are over.
Two Phase Locking (2PL) Protocol
This locking protocol divides the execution phase of a transaction into three
different parts.
In the first phase, when the transaction begins to execute, it requires permission
for the locks it needs.
The second part is where the transaction obtains all the locks. When a transaction
releases its first lock, the third phase starts.
In this third phase, the transaction cannot demand any new locks. Instead, it only
releases the acquired locks.
Strict Two-Phase Locking Method
Strict-Two phase locking system is almost similar to 2PL. The only difference is
that Strict-2PL never releases a lock after using it. It holds all the locks until the
commit point and releases all the locks at one go when the process is over.
Timestamp-based Protocols
The timestamp-based algorithm uses a timestamp to serialize the execution of concurrent
transactions.
This protocol ensures that every conflicting read and write operations are executed
in timestamp order. The protocol uses the System Time or Logical Count as a Timestamp.
Example:
Suppose there are three transactions T1,T2,T3
T1 has entered the system at time 0010
T2 has entered the system at time 0020
T3 has entered the system at time 0030
Priority will be given to the transaction T1, then transaction T2 then transaction T3.
Recovery
Recovery Control in Distributed Databases. As with
local recovery, distributed database recovery aims to maintain
the atomicity and durability of distributed transactions.
A database must guarantee that all statements in a transaction ,
distributed or non-distributed, either commit or roll back as a
unit.
Recovery methods
Salvation Program – a post-crash process that tries to restore
the DB to a valid state. No recovery data used.
Incremental Dumping – Copies updated files to archival
storage. Performed either after TX completion or regular
intervals.
Audit Trail – Keeps track of a sequence of actions. Useful for
DB restoration to pre-crash state.
Differential Files – separate files records updates requested
for records in a main file.
Backup/Current Version – current version of DB is stored
in currently existing files with present values.
Multiple Copies – multiple identical copies of the DB files
are maintained.
Careful Replacement – Update performed on a copy.
Original is deleted upon commit. Original copy available
after a crash during update.
THANK YOU

Overview of Concurrency Control & Recovery in Distributed Databases

  • 1.
    “Overview of Concurrencycontrol and recovery in distributed database” Presented by : Prashi Jain Roll No. : MA/25022/18
  • 2.
    What is concurrencycontrol  Concurrency control is the procedure in DBMS for managing simultaneous operations without conflicting with each another.  Concurrent access is quite easy if all users are just reading data. There is no way they can interfere with one another.  Though for any practical database, would have a mix of reading and WRITE operations and hence the concurrency is a challenge.
  • 3.
    Why use Concurrencymethod?  To apply Isolation through mutual exclusion between conflicting transactions. To resolve read-write and write-write conflict issues To preserve database consistency through constantly preserving execution obstructions The system needs to control the interaction among the concurrent transactions. This control is achieved using concurrent-control schemes. Concurrency control helps to ensure serializability
  • 4.
    Example Assume that twopeople 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, 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.
  • 5.
    Concurrency Control Protocols Inorder to maintain the concurrent access of transactions, two protocols are introduced :- 1- lock based protocol 2- time stamp based protocol
  • 6.
    Lock based protocol Alock is applied to avoid concurrency problem between two transaction in such a way that the lock is applied on one transaction and other transaction can access it only when the lock is released. The lock is applied on write or read operations. These locks are broadly classified into:- 1- binary locks:- In binary lock data can either be locked or unlocked. It will have only these two states. 2-Shared/exclusive locks:- data is said to be exclusively locked if for insert / update /delete. When it is exclusively locked no other transaction can read or write the data. When a data is read from the database, then its lock is shared i.e.; the data can be read by other transaction too but it cannot be changed while retrieving the data.
  • 7.
    Lock based protocolsare of 4 types  Simplistic Lock Protocol: - This protocol allows all the transaction to get the lock on the data before insert / update /delete on it. After completing the transaction, it will unlock the data.  Pre-claiming Protocol: - Pre-claiming lock protocol helps to evaluate operations and create a list of required data items which are needed to initiate an execution process. In the situation when all locks are granted, the transaction executes. After that, all locks release when all of its operations are over.
  • 8.
    Two Phase Locking(2PL) Protocol This locking protocol divides the execution phase of a transaction into three different parts. In the first phase, when the transaction begins to execute, it requires permission for the locks it needs. The second part is where the transaction obtains all the locks. When a transaction releases its first lock, the third phase starts. In this third phase, the transaction cannot demand any new locks. Instead, it only releases the acquired locks.
  • 9.
    Strict Two-Phase LockingMethod Strict-Two phase locking system is almost similar to 2PL. The only difference is that Strict-2PL never releases a lock after using it. It holds all the locks until the commit point and releases all the locks at one go when the process is over.
  • 10.
    Timestamp-based Protocols The timestamp-basedalgorithm uses a timestamp to serialize the execution of concurrent transactions. This protocol ensures that every conflicting read and write operations are executed in timestamp order. The protocol uses the System Time or Logical Count as a Timestamp. Example: Suppose there are three transactions T1,T2,T3 T1 has entered the system at time 0010 T2 has entered the system at time 0020 T3 has entered the system at time 0030 Priority will be given to the transaction T1, then transaction T2 then transaction T3.
  • 11.
    Recovery Recovery Control inDistributed Databases. As with local recovery, distributed database recovery aims to maintain the atomicity and durability of distributed transactions. A database must guarantee that all statements in a transaction , distributed or non-distributed, either commit or roll back as a unit.
  • 12.
    Recovery methods Salvation Program– a post-crash process that tries to restore the DB to a valid state. No recovery data used. Incremental Dumping – Copies updated files to archival storage. Performed either after TX completion or regular intervals. Audit Trail – Keeps track of a sequence of actions. Useful for DB restoration to pre-crash state.
  • 13.
    Differential Files –separate files records updates requested for records in a main file. Backup/Current Version – current version of DB is stored in currently existing files with present values. Multiple Copies – multiple identical copies of the DB files are maintained. Careful Replacement – Update performed on a copy. Original is deleted upon commit. Original copy available after a crash during update.
  • 14.