Optimistic concurrency control: Difference between revisions

Content deleted Content added
No edit summary
Line 3:
Optimistic Concurrency Control is based on the assumption that [[database transaction]]s mostly don't conflict with other transactions, and that allows OCC to be as permissive as possible in allowing transactions to execute.
 
There are three phases in an OCC transaction:
 
1. '''READ''': TransactionThe executes,client readingreads values from the database, writingstoring them to a private [[sandbox (security)|sandbox]] or cache that the client can then edit.
 
2. '''VALIDATION''': When the client has completed editing of the values in its sandbox or cache, it initiates the storage of the changes back to the database. During validation, an algorithm checks if the changes to the data would conflict with either i) already-committed transactions in the case of ''Backward Validation Schemes'', or ii) currently executing transactions in the case of ''Forward Validation Schemes''. If a conflict exists, a Conflict Resolution Algorithm must be used to resolve the conflict somehow (ideally by minimizing the number of changes made by the user) or, as a last resort, the entire transaction can be aborted (resulting in the loss of all changes made by the user).
2. '''VALIDATION''': When transaction commits, the database checks if the transaction could have possibly conflicted with any other concurrent transaction. If there is a possibility, the transaction aborts, and restarted.
 
3. '''WRITE''': If there is no possibility of conflict, the transactions commits.