Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 16

Concurrency Control Based On Timestamp

Ordering

Guided By: Presented By:


Dr Maheshwari L Patil Poojitha G L : 4GM21CS067
Asst. Prof, Department of CSE Ranjita U Kummur : 4GM21CS082
GM Institute of Technology Sanjana V Jadhav : 4GM21CS094
Davanagere Shreya NMH : 4GM21CS100
Overview of Concurrency Control
 Concurrency control is a fundamental
concept in database management
systems that ensures the correctness and
consistency of database transactions that
are executed concurrently.
 It prevents conflicts and ensures that
transactions are executed in an isolated
and consistent manner.
Locking and 2PL Protocol
1 Locking Mechanism
Locking is a fundamental concept in database
concurrency control, used to manage simultaneous
transaction executions and maintain data integrity.

2 2PL Protocol
The Two-Phase Locking (2PL) protocol ensures that
the schedules are serializable and that transactions
occur in a controlled manner.

3 Handling Deadlocks
While effective, the 2PL protocol can lead to
deadlocks, requiring transactions to be aborted and
restarted to resolve conflicts.
Timestamp Ordering for Concurrency Control

Timestamps Deadlock Avoidance

Timestamps serve as Unlike locking


unique identifiers for mechanisms, timestamp
transactions, assigned in ordering does not use
the order of transaction locks, thereby eliminating
submissions, and are the possibility of
crucial for timestamp- deadlocks.
based concurrency
control.
Generating Timestamps

Timestamps can be generated using a counter or


the system clock, ensuring each transaction has a
distinct timestamp.

There are different methods for generating


timestamps, including:
I. System Clock
II. Logical Clock
III. Hybrid Methods
The Timestamp Ordering Algorithm for Concurrency Control

 The timestamp ordering algorithm is a method used in concurrency control to enforce


an equivalent serial order of transactions based on their timestamps.
 This algorithm ensures that transactions are executed in a way that maintains the
consistency and integrity of the database.

Transaction 1 Transaction 2 Transaction 3 Transaction 4


Timestamp Ordering Algorithm

Read and Write Operation Checks Conflict Serializable


Timestamps The algorithm Schedules
Each database item is performs checks to By following the
associated with a read ensure that conflicting timestamp order, the
and write timestamp, operations adhere to algorithm guarantees
reflecting the latest the timestamp order, that the schedules
transactions that have aborting transactions if produced are conflict
accessed the item. necessary. serializable.
Basic Timestamp Ordering (TO)

 The basic timestamp ordering (TO) algorithm


resolves conflicts between concurrent
operations by comparing their timestamps.
 If two operations conflict, the algorithm
ensures that the operation with the earlier
timestamp is executed first.
Basic Timestamp Ordering (TO)

1 Read/Write Operations 2 Cascading Rollback


Transactions issue read or Transactions may be rolled back in a cascade if
write operations, which are they depend on the operations of aborted
checked against item transactions, highlighting a challenge of basic
timestamps to maintain TO.
order.
3 Recoverability Protocols
To ensure recoverability, additional protocols are applied to the
basic TO algorithm, preventing non-recoverable schedules.
Strict Timestamp Ordering (STO)

Strict Schedules Delaying Operations


Strict Timestamp Ordering (STO) Operations are delayed until the relevant
variation ensures schedules are transactions have committed or aborted,
strict, aiding in easier ensuring order and recoverability.
recoverability.

Lock Simulation
STO simulates the locking of items to manage access
until transactions are resolved, without causing
deadlocks.
Thomas's Write Rule:

 Thomas's Write Rule is a modification of the basic Timestamp Ordering


(TO) algorithm used in concurrency control.

 It aims to reduce the number of rejected write operations in a distributed


database system.

 Thomas's Write Rule allows write operations with earlier timestamps to be


accepted if they do not conflict with any pending read or write operations.

 This reduces the number of rejected write operations and improves


system performance.
Thomas's Write Rule

5 6 7
Abort Ignore Execute
If a read timestamp is greater If a write timestamp is When conditions allow, the
than the transaction's greater, the write operation is write operation is executed
timestamp, the transaction is ignored to avoid outdated and the write timestamp is
aborted. operations. updated.
Application and Benefits of Thomas's Writes Rule :

Reliability Data Integrity High Availability


 By immediately writing every change to  It ensures the integrity of the data,  The rule facilitates high availability
disk, Thomas's Writes Rule ensures the preventing incomplete or incorrect data of the database, ensuring that the
reliability of the data, reducing the risk of from being retrieved after a system system can quickly recover from
data loss due to system failures. failure or crash. failures without loss of data.
Conclusion:

Effectiveness
Timestamp ordering provides a reliable method for managing simultaneous database transactions and
ensuring data integrity.

Suitability
It is particularly suitable for scenarios requiring strict control over the order of transaction execution and
consistent data management.

Overall Verdict
When used judiciously, concurrency control based on timestamp ordering is a valuable tool in database
management, offering a good balance between performance and data integrity.
References:

 Fundamental of Database System ,7th edition by Ramez Elmasri And Shamakanth


B.Navathe
 https://youtu.be/27NtGV1vNoY?si=tXGnIWKl-D8VfQgc

You might also like