0% found this document useful (0 votes)
83 views

Topic2 Transaction Processing Part 2

The document discusses three problems that can plague transactions when concurrency controls are present: 1) the lost update problem, 2) the uncommitted dependency problem, and 3) the inconsistent analysis problem. Each problem is caused by transactions simultaneously accessing and modifying the same data. Proper locking and isolation of transactions are needed to prevent inaccurate and inconsistent data from being committed to the database.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views

Topic2 Transaction Processing Part 2

The document discusses three problems that can plague transactions when concurrency controls are present: 1) the lost update problem, 2) the uncommitted dependency problem, and 3) the inconsistent analysis problem. Each problem is caused by transactions simultaneously accessing and modifying the same data. Proper locking and isolation of transactions are needed to prevent inaccurate and inconsistent data from being committed to the database.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 15

TU2983 : Advanced Databases

1
 The following 3 problems frequently
plague transactions when there are
concurrency controls:

1. The Lost Update Problem


2. The Uncommitted Dependency Problem
3. The Inconsistent Analysis Problem

2
 This problem occurs when two transactions
are accessing the same data, and
simultaneously alters that data.

 One operation by one user, which has been


seen/witnessed/verified as complete, is
overwritten by another operation by a
different user.

3
Time User 1 User 2 balx
t1 Start transaction 100
t2 Start transaction READ (balx) 100
t3 READ (balx) balx = balx + 100 100
t4 balx= balx – 10 WRITE(balx) 200
t5 WRITE(balx) COMMIT 90
t6 COMMIT 90

4
 The WRITE process to balx for User 2 is not
recorded and ‘missing’.

 User 2 does not know that his transaction is


unrecorded.

 The end result after updates to balx for User


1’s transaction shows the incorrect value.

5
 The problem can be avoided by preventing
User 1 from reading balx until the update
transaction by User 2 is complete.

6
 The problem occurs when there are
transactions that access data that has not
been committed, and the data reverts/rolls-
back to its original value.

 The new transaction will be processing the


incorrect data.

 Also called the “dirty read problem”.

7
Time User 1 User 2 balx
t1 Start transaction 100
t2 READ (balx) 100
t3 balx = balx+ 100 100
t4 Start transaction WRITE(balx) 200
t5 READ (balx) … 200
t6 balx=balx– 10 ROLLBACK 100
t7 WRITE(balx) 190
t8 COMMIT 190
8
 The value balx = 200 which is retrieved by
User 1’s transaction is incorrect.

 The ROLLBACK process should have


reverted the value of balx to its original
value, which is balx = 100.

 User 1’s transaction will result in incorrect


data being written in the database .

9
 The problem can be avoided by preventing
User 1 from reading balx until a decision is
made on whether or COMMIT or ROLLBACK
User 2’s transactions.

10
 Problems can also occur during the process
of reading data from the database.

 The problems occur when there are 2 or more


transactions that operate on the same set of
data, and one transaction updates the data
before other transactions are completed.

11
 Example
◦ User 1 wants to transfer 10 from balx
to balz.

◦ User 2 wants to sum the values of


balx, baly, and balz

12
Time User 1 User 2 balx baly balz Total
t1 Start transaction 100 50 25
t2 Start transaction Total = 0 100 50 25 0
t3 READ (balx) READ (balx) 100 50 25 0
t4 balx=balx– 10 Total =Total + balx 100 50 25 100
t5 WRITE(balx) READ (baly) 90 50 25 100
t6 READ (balz) Total =Total + baly 90 50 25 150
t7 balz=balz+10 90 50 25 150
t8 WRITE(balz) 90 50 35 150
t9 COMMIT READ (balz) 90 50 35 150
t10 Total =Total + balz 90 50 35 185
t11 COMMIT 90 50 35 185
13
 The TOTAL value is incorrect because it does
not account for the reduction of 10 in balx in
the transfer to balz.

14
 The problem can be avoided if User 2 is
prevented from reading balx and balz until
User 1’s transaction has completed.

15

You might also like