×

Concurrent Execution of Transaction

In the transaction process, a system usually allows executing more than one transaction simultaneously. This process is called a concurrent execution.

Advantages of concurrent execution of a transaction

  1. Decrease waiting time or turnaround time.
  2. Improve response time
  3. Increased throughput or resource utilization.

Concurrency problems

Several problems can occur when concurrent transactions are run in an uncontrolled manner, such type of problems is known as concurrency problems.

There are following different types of problems or conflicts which occur due to concurrent execution of transaction:

1. Lost update problem (Write – Write conflict)

This type of problem occurs when two transactions in database access the same data item and have their operations in an interleaved manner that makes the value of some database item incorrect.

If there are two transactions T1 and T2 accessing the same data item value and then update it, then the second record overwrites the first record.

Example: Let's take the value of A is 100

Time Transaction T1 Transaction T2
t1 Read(A)  
t2 A=A-50  
t3   Read(A)
t4   A=A+50
t5 Write(A)  
t6   Write(A)

Here,

  • At t1 time, T1 transaction reads the value of A i.e., 100.
  • At t2 time, T1 transaction deducts the value of A by 50.
  • At t3 time, T2 transactions read the value of A i.e., 100.
  • At t4 time, T2 transaction adds the value of A by 150.
  • At t5 time, T1 transaction writes the value of A data item on the basis of value seen at time t2 i.e., 50.
  • At t6 time, T2 transaction writes the value of A based on value seen at time t4 i.e., 150.
  • So at time T6, the update of Transaction T1 is lost because Transaction T2 overwrites the value of A without looking at its current value.
  • Such type of problem is known as the Lost Update Problem.

Dirty read problem (W-R conflict)

This type of problem occurs when one transaction T1 updates a data item of the database, and then that transaction fails due to some reason, but its updates are accessed by some other transaction.

Example: Let's take the value of A is 100

Time Transaction T1 Transaction T2
t1 Read(A)  
t2 A=A+20  
t3 Write(A)                  
t4   Read(A)
t5   A=A+30
t6   Write(A)
t7 Write(B)  

Here,

  • At t1 time, T1 transaction reads the value of A i.e., 100.
  • At t2 time, T1 transaction adds the value of A by 20.
  • At t3 time, T1transaction writes the value of A (120) in the database.
  • At t4 time, T2 transactions read the value of A data item i.e., 120.
  • At t5 time, T2 transaction adds the value of A data item by 30.
  • At t6 time, T2transaction writes the value of A (150) in the database.
  • At t7 time, a T1 transaction fails due to power failure then it is rollback according to atomicity property of transaction (either all or none).
  • So, transaction T2 at t4 time contains a value which has not been committed in the database. The value read by the transaction T2 is known as a dirty read.

Unrepeatable read (R-W Conflict)

It is also known as an inconsistent retrieval problem. If a transaction T1 reads a value of data item twice and the data item is changed by another transaction T2 in between the two read operation. Hence T1 access two different values for its two read operation of the same data item.

Example: Let's take the value of A is 100

Time Transaction T1 Transaction T2
t1 Read(A)  
t2   Read(A)
t3   A=A+30
t4   Write(A)
t5 Read(A)  

Here,

  • At t1 time, T1 transaction reads the value of A i.e., 100.
  • At t2 time, T2transaction reads the value of A i.e., 100.
  • At t3 time, T2 transaction adds the value of A data item by 30.
  • At t4 time, T2 transaction writes the value of A (130) in the database.
  • Transaction T2 updates the value of A. Thus, when another read statement is performed by transaction T1, it accesses the new value of A, which was updated by T2. Such type of conflict is known as R-W conflict. 

Related Topics

Advantages of RDBMS

The relational database management system collects related data stored in tabular format. The data is stored in rows and columns, where rows usually represent the individual entity of the collected...

6 minutes read.

DBMS Languages

User can access, update, delete, and store data or information in the database using database languages. The following are the databases languages in the database management system: Data Definition Language Data Manipulation...

3 minutes read.

3- Tier Architecture in DBMS

Three-tier architecture is an application software architecture that arranges the output into three parts or tiers that are:  the presentation tier, where the user interacts with the application; the application...

4 minutes read.

ER Diagram for Student Management System in DBMS

Entity Relationship diagrams Entity Relationship Diagrams, or ER Diagrams for short, are diagrams that show the relationships among entity sets that are stored in databases. Alternatively said, ER diagrams assist in...

6 minutes read.

Specialization in DBMS

Specialization in DBMS In the database management system, specialization breaks the higher-level entity into two or more than two lower entities. The main motive of this concept is to share the...

2 minutes read.

Advantages of B-Tree in DBMS

A self-balancing search tree is the B-Tree. It is assumed that everything is in the main memory in most other self-balancing search trees (such as AVL and Red-Black Trees). We must...

3 minutes read.

Data Models in DBMS

Data Models in DBMS Data models are the models explaining the logical structure of the database systems. They describe the entities, attributes, and the relationship among the data elements of the...

8 minutes read.

Applications of DBMS

There are various fields where a database management system is used. Following are some applications which make use of the database management system: 1. Railway Reservation System: In the railway reservation...

7 minutes read.

What is Transaction in DBMS

A transaction is a collection of logically related operations which reads and possibly updates the various data items in the database. Usually, a transaction is initiated by a user program written in high-level...

3 minutes read.

Components of an ER Diagram

An ER Diagram consists of the following components: Entity AttributesRelationships 1. Entity An entity may be an object, place, person, or an event which stores data in the database. In an entity-relationship diagram, an entity...

4 minutes read.

Conversion of ER Diagram into Relational Model

After designing the Entity-Relationship diagram, you need to convert it into tables in the relational model. Because the relational model can be easily implemented by the Relational DBMS like Oracle, MySQL, etc....

2 minutes read.

Serializability in DBMS

Serializability in DBMS Serializability is the concept in a transaction that helps to identify which non-serial schedule is correct and will maintain the database consistency. It relates to the isolation property of transaction in...

3 minutes read.

Anomalies in Database Management System

Anomalies in a database management system (DBMS) are problems that can arise when the database is not designed or implemented correctly. These anomalies can affect the integrity and accuracy of...

3 minutes read.

DBMS Schema

Schema It is a physical representation of data that appears in the database management system. In simple words, a schema is the structure of any database.It defines how the data is stored...

2 minutes read.

Network model in DBMS

Network model: The many-to-many relationship between the database constraints is represented hierarchically by the Network Model in DBMS. It is a straightforward and straightforward database model. Due to the Network Model...

4 minutes read.

Domain in DBMS

Constraints: Constraints in DBMS are a set of guidelines that guarantee that authorized users who modify the database do not alter the consistency of the data. Constraints are expressed in DDL...

3 minutes read.

Defference between Database and Data Warehouse

Database A database is a collection of related information is called a database. It has some elements that can be mapped to real-world objects. It is designed in such a manner...

4 minutes read.

Characteristics of DBMS

Introduction to DBMS: A database management system (DBMS) is a software application that is designed to manage and organize data stored in a database. It is responsible for storing, retrieving, and...

3 minutes read.

B+ (Plus) Tree in DBMS

What is a B+ tree? The B+ tree is known as a balanced binary search tree. in this tree, we can store the data in the form of nodes. B+ tree...

9 minutes read.

Normalization in DBMS: 1NF, 2NF, 3NF, BCNF & 4NF with Examples

Normalization is a technique of organizing the data in the database. It is a systematic approach which is used to remove or reduce data redundancy in the tables and remove the...

7 minutes read.