CONCURRENT EXECUTION IN DBMS
In a multi-user system, multiple users can access and manipulate the same database simultaneously, a process known as concurrent execution. This capability is fundamental to modern database systems, enabling efficient use of resources and improved system performance. However, concurrent execution also introduces challenges that must be managed to ensure data integrity and consistency.
Concurrent execution in Database Management Systems (DBMS) refers to multiple database transactions being processed simultaneously. This is crucial for improving performance and ensuring efficient utilization of system resources.
In a database transaction, the two main operations are READ and WRITE operations..While concurrent execution offers numerous benefits, it also introduces several challenges, mainly due to the interactions between concurrent transactions.
Occurs when two transactions read the same data and update it, but one update is overwritten by the other, leading to lost data changes.
Example:
Occurs when a transaction reads data that has been written by another transaction that has not yet committed. If the other transaction rolls back, the data read by the first transaction becomes invalid.
Example:
Occurs when a transaction reads the same data multiple times and gets different results because other transactions are concurrently updating the data.
Example:
EXAMPLE: ONLINE BANKING SYSTEM
Consider an online banking system where multiple users can access and modify their account balances simultaneously. This scenario is common in the real world and illustrates the potential problems of concurrent execution.
Situation: Two customers, Alice and Bob, try to transfer money from a joint savings account at the same time.
Transactions:
Execution:
Problem: The update by Alice is lost because Bob's transaction overwrites it. The final balance should be $500 (i.e., $1000 - $200 - $300), but it ends up being $700.
Situation: A bank manager is generating a report on account balances while another transaction is updating balances.
Transactions:
Execution:
Problem: The manager's report shows an incorrect balance of $1200 because it was based on uncommitted data.
Situation: A customer is checking their account balance and recent transactions.
Transactions:
Execution:
Problem: The customer sees inconsistent data: the initial balance check shows $1000, but a subsequent check shows $700, causing confusion.