Characterizing Schedules Based on Serializability


Introduction

In the field of database management systems, concurrency control is an important aspect of maintaining the consistency of data. One of the most widely used methods for ensuring consistency is serializability, which is a concept that characterizes schedules based on their ability to produce the same results as if the transactions were executed one at a time in some order. In this article, we will explore the concept of serializability in scheduling and how it can be used to ensure consistency in a concurrent system.

What is Serializability?

Serializability is a concept that is used to ensure that the concurrent execution of multiple transactions does not result in inconsistencies or conflicts in a database management system. In other words, it ensures that the results of concurrent execution of transactions are the same as if the transactions were executed one at a time in some order.

A schedule is considered to be serializable if it is equivalent to some serial schedule, which is a schedule where all transactions are executed one at a time. This means that if a schedule is serializable, it does not result in any inconsistencies or conflicts in the database.

Types of Schedules

There are two types of schedules: serial schedules and concurrent schedules. A serial schedule is one where all transactions are executed one at a time, and a concurrent schedule is one where multiple transactions are executed simultaneously.

A schedule is considered to be conflict serializable if it is equivalent to some serial schedule. A schedule is considered to view serializable if it is equivalent to some serial schedule, but the order of the transactions may be different.

Testing for Serializability

There are several methods for testing if a schedule is serializable, including −

  • Conflict serializability − A schedule is conflict serializable if it is equivalent to some serial schedule and does not contain any conflicting operations.

  • View serializability − A schedule is a view serializable if it is equivalent to some serial schedule, but the order of the transactions may be different.

To check for conflict serializability, we can use the conflict graph method which involves creating a graph where each transaction is represented by a node and each conflicting operation is represented by an edge. A schedule is considered to be conflict serializable if there are no cycles in the graph.

To check for view serializability, we can use the view equivalence method which involves comparing the results of a schedule with the results of a serial schedule. If the results are the same, the schedule is considered to be view serializable.

Concurrency Control Techniques

There are several techniques that can be used to ensure that a schedule is serializable, including −

  • Locking − This technique involves placing locks on specific data items to prevent conflicting operations from being executed simultaneously.

  • Time stamping − This technique involves assigning a unique time stamp to each transaction, and transactions are executed in order of their time stamp.

  • Optimistic concurrency control − This technique involves allowing transactions to be executed concurrently, but checking for conflicts at commit time.

Example

BEGIN TRANSACTION READ(A) READ(B) A = A + 1 B = B + 1 WRITE(A) WRITE(B) COMMIT

In the above example, we have two transactions T1 and T2 that are executed concurrently. T1 reads the value of A and B, increments them by 1, and writes the new values back to the database. T2 also reads the value of A and B, increments them by 1, and writes the new values back to the database.

If T1 and T2 are executed in a serial schedule, the final values of A and B will be 2. But if they are executed concurrently, there is a possibility of a conflict as both T1 and T2 are trying to update the same values simultaneously. This can result in an inconsistent state.

To prevent this type of conflict, we can use concurrency control techniques like locking or time stamping. For example, if we use locking, T1 would acquire a lock on A and B before reading and updating them, and T2 would have to wait until T1 releases the lock before it can acquire the lock and execute its operations. This ensures that T1 and T2 are not executing their operations on the same data simultaneously and thus avoiding conflict.

Another example of serializability in real life would be in an e-commerce platform. Two customers, A, and B are trying to purchase the last available item in a store. If the transactions were executed in a serial schedule, customer A would purchase the item and customer B would be notified that the item is out of stock.

But if the transactions were executed concurrently, there is a possibility of a conflict as both A and B are trying to purchase the same item simultaneously. To prevent this type of conflict, we can use a technique like time stamping, where the first customer to click the “purchase” button gets the item and the other customer is notified that the item is no longer available.

Conclusion

Serializability is an important concept in database management systems that is used to ensure consistency and prevent conflicts in concurrent systems. It characterizes schedules based on their ability to produce the same results as if the transactions were executed one at a time in some order. There are several techniques that can be used to ensure serializability, including locking, time stamping, and optimistic concurrency control. By understanding and implementing these techniques, we can ensure that our concurrent systems are consistent and reliable.

Updated on: 16-Jan-2023

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements