Session A at T1 says, "Lock d=5 row, don't allow other transactions to read or write, break."īecause if we insert d=5 at this point, the new data is not protected by the lock. Phantom just means "newly inserted row" Problems with illusory reading The result of session B modification is seen by the current read statement after session A, and cannot be called phantom read. Under repeatable read isolation, normal queries are snapshot reads and do not see data inserted by other transactions.Ģ. Phantom read is for insert data inconsistency, unrepeatable read is for DELETE, update data inconsistency.ġ. In the same transaction, two different reads are called illusory reads and unrepeatable reads. The difference between illusory and unrepeatable Phantom reading is when a transaction queries the same range twice before and after, and the latter query sees rows not seen by the previous query. Session A performs three current reads and adds A write lock. If the row with id=5 is locked and the other rows are not, in the following case: Will other scanned rows that do not meet the requirements be locked? Phantom read phenomenon Since there is no index on field D, this query will do a full table scan. Due to the two-phase lock protocol, this write lock will be released at commit time. Therefore, after the SELECT statement completes, a write lock will be added to the row ID =5. This statement will hit the row d=5, corresponding to the primary key ID =5. In the following statement sequence, how is the lock added and when is the lock released? begin In addition to primary key ID, this table also has index C.
0 Comments
Leave a Reply. |