Which of the following phenomena occurs when a transaction rereads data it has previously read and finds that the data has been modified or deleted by another committed transaction?

Difficulty: Medium

Correct Answer: Nonrepeatable read

Explanation:


Introduction / Context:
Transaction isolation in database systems aims to prevent anomalies that arise when multiple transactions execute concurrently. Different isolation levels control which phenomena are allowed, such as dirty reads, nonrepeatable reads, and phantom reads. This question focuses on a specific anomaly where a transaction rereads the same row and discovers that the data has changed due to a committed update or delete by another transaction.


Given Data / Assumptions:

  • We are dealing with transactions that run concurrently in a DBMS.
  • One transaction reads a row and later reads the same row again.
  • In the meantime, another transaction commits changes to that row.
  • The first transaction then sees different data on the second read.


Concept / Approach:
A nonrepeatable read occurs when a transaction reads the same row twice and gets different values because another transaction has modified and committed changes between the reads. This differs from a dirty read, where a transaction reads uncommitted changes, and from a phantom read, where the set of rows returned by a query changes because new rows have been inserted or existing rows have been deleted. A consistent read is a general term for reading data that appears stable with respect to some snapshot or isolation level and is not the name of an anomaly.


Step-by-Step Solution:
Step 1: Focus on the behavior described: rereading previously read data and seeing modifications or deletions after another transaction commits.Step 2: Recall that nonrepeatable read is defined as exactly this situation at the row level.Step 3: Distinguish it from dirty read, which involves reading uncommitted changes, and from phantom read, which involves changes in the set of rows returned.Step 4: Recognize that consistent read is not an anomaly type but a desirable property.Step 5: Conclude that the described anomaly is a nonrepeatable read.


Verification / Alternative check:
You can verify by imagining a simple scenario. Transaction T1 reads the balance of an account as 100. Transaction T2 then updates the same account balance to 150 and commits. When T1 reads the balance again, it now sees 150. T1 has experienced a nonrepeatable read because the same row produced different results between reads due to a committed update by another transaction. No new rows were created or removed, so this is not a phantom read, and the second read did not involve uncommitted data, so it is not a dirty read.


Why Other Options Are Wrong:
Option B, phantom read, occurs when a transaction re executes a query and sees additional or missing rows, usually due to inserts or deletes by other committed transactions, not just changes to existing row values. Option C, dirty read, involves reading data that has been written by another transaction but has not yet been committed, which is different from the scenario described. Option D, consistent read, is a term sometimes used to describe isolation mechanisms that provide a stable snapshot of data, not an error or anomaly by itself.


Common Pitfalls:
Students often confuse nonrepeatable reads and phantom reads because both involve rereading data. The key difference is that nonrepeatable reads involve changes to existing rows, while phantom reads involve changes to the set of rows returned. Another pitfall is to mix up dirty reads, which are about uncommitted data, with nonrepeatable reads, which involve committed changes. Learning precise definitions for each anomaly helps in understanding isolation levels such as Read Committed, Repeatable Read, and Serializable.


Final Answer:
The anomaly described is called a Nonrepeatable read, which corresponds to option A.

More Questions from Database

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion