week 10
Teaching and Learning Methods to be Employed
1. Illustrated lecture on transactions, ACID properties, and isolation levels
2. Concurrency problem demonstration with parallel transaction scenarios
3. Recovery mechanisms and log-based recovery exercise
4. Final course review and exam preparation session
Learning Outcomes / Objectives
By the end of this week, students should be able to:
1. Define a transaction and explain the ACID properties.
2. Describe the concurrency problems that arise when transactions execute simultaneously.
3. Explain lock-based and timestamp-based concurrency control protocols.
4. Describe transaction isolation levels and their trade-offs.
5. Explain the concept of database failure and recovery.
6. Describe log-based recovery and the ARIES algorithm concepts.
10.3 Concurrency Problems
When multiple transactions execute simultaneously without proper control, several problems can occur:
|
Concurrency Problem |
Description and Example |
|
Lost Update |
Two transactions read the same data and both update it, but one update overwrites the other. E.g., two bank tellers simultaneously process deposits to the same account — one deposit is lost. |
|
Dirty Read |
Transaction T2 reads data written by T1 before T1 commits. If T1 rolls back, T2 has read invalid data. E.g., T2 reads a balance that T1 just updated but then rolled back — T2 acts on a 'phantom' value. |
|
Non-Repeatable Read |
T1 reads a value, T2 updates it and commits, T1 reads it again and gets a different value. E.g., a report reads an account balance, another transaction changes it, the report reads it again — inconsistent report. |
|
Phantom Read |
T1 executes a query returning a set of rows, T2 inserts/deletes rows matching T1's criteria, T1 repeats the query and gets different rows. E.g., counting active loans — a new loan is added mid-count. |