In optimistic concurrency control, what happens when two transactions try to update the same data at the same time?
Think about how optimistic concurrency control trusts transactions to not conflict but checks before finalizing.
Optimistic concurrency control allows transactions to proceed without locking. At commit time, it checks if data was changed by others. If yes, it rolls back one transaction to avoid conflicts.
Optimistic concurrency control typically involves three phases. Which of the following is NOT one of them?
Optimistic concurrency control avoids locking during the transaction.
Optimistic concurrency control does not lock data before reading. It reads and modifies data locally, then validates before writing changes.
Consider a system with many users mostly reading data and rarely updating. Why is optimistic concurrency control often preferred here?
Think about how locking affects performance when conflicts are uncommon.
Optimistic concurrency control avoids locking, so transactions don't wait. This is efficient when conflicts are rare, unlike pessimistic control which locks data and can cause delays.
During the validation phase, a transaction detects that the data it read was changed by another transaction. What is the correct outcome?
Consider how data integrity is maintained when conflicts are detected.
If validation fails, the transaction cannot safely commit because data changed. It must roll back and retry to ensure consistency.
In a system with many concurrent updates to the same data, why does optimistic concurrency control lead to more transaction rollbacks?
Think about what happens when many transactions try to update the same data without locks.
Without locking, many transactions may read stale data and conflict at validation, causing rollbacks. High contention increases these conflicts.