Difficulty: Medium
Correct Answer: The lock is obtained only when the transaction is ready to write or commit changes.
Explanation:
Introduction / Context:
Optimistic locking is a concurrency control strategy that assumes conflicts are rare. Instead of locking rows up-front, transactions proceed and validate at commit time, improving throughput when contention is low.
Given Data / Assumptions:
Concept / Approach:
Optimistic locking avoids holding locks during long business logic phases. It typically uses a version/timestamp check at update time. If another transaction has changed the row, the update fails and must be retried. The benefit is reduced blocking and better scalability under low-conflict patterns.
Step-by-Step Solution:
Verification / Alternative check:
Empirical performance studies show optimistic techniques excel when conflicts are rare because they minimize blocking and deadlocks, though they may degrade with frequent conflicts due to retries.
Why Other Options Are Wrong:
Common Pitfalls:
Final Answer:
The lock is obtained only when the transaction is ready to write or commit changes.
Discussion & Comments