ITPEC FE Morning October 2019 Question 31
Which of the following is an appropriate description of the lock operation that is used for the concurrency control of a transaction?
Explanation
A second shared lock is permitted on a shared-locked resource — shared locks are for reading, and any number of readers can hold them at once.
A transaction takes a shared lock to read and an exclusive lock to update. Reads do not change the data, so they do not conflict with each other; an update conflicts with everything. The compatibility table:
Answer (a)
Why not others:
- •(b) — an exclusive lock on data others are reading would let it change under them; the writer waits until the shared locks are released
- •(c) — reading data another transaction is updating would expose uncommitted values (a dirty read), so the reader waits
- •(d) — two transactions updating the same data at once could overwrite each other (a lost update), so the second waits
Key rule: Only shared with shared is compatible; as soon as either side is exclusive, the second request waits.
Databases · AI-written, may contain errors
This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.