Questions: Pessimistic Concurrency Control: Locking

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

Transaction A executes UPDATE orders SET status='shipped' WHERE id=1, then continues running other operations. Transaction B tries to read row id=1. Which statement is correct?

ATransaction B can read the row because Transaction A's UPDATE statement has already completed
BTransaction B must wait because Transaction A still holds the exclusive lock on that row until it commits or rolls back
CTransaction B can proceed using a shared lock since it is only reading, not modifying
DTransaction B's wait will automatically time out when the UPDATE statement finishes
Question 2 Multiple Choice

Transaction A locks row X then waits for row Y. Transaction B locks row Y then waits for row X. What will the database do?

ABoth transactions will eventually proceed once the database serializes their lock requests
BA deadlock will be detected; the database will abort one transaction to break the cycle so the other can proceed
CBoth transactions will wait indefinitely until an administrator manually kills one
DThe second lock request in each transaction will immediately fail with a lock-not-available error
Question 3 True / False

Pessimistic concurrency control is called 'pessimistic' because it acquires locks upfront, assuming conflicts are likely, rather than checking for conflicts at commit time.

TTrue
FFalse
Question 4 True / False

A shared (read) lock prevents other transactions from reading the same row simultaneously.

TTrue
FFalse
Question 5 Short Answer

Why can a long-running transaction significantly reduce database throughput even if it never actually conflicts with other transactions?

Think about your answer, then reveal below.