Optimistic locking is a strategy where you read a record, take note of a version number and check that the version hasn't changed before you write the record back. If the record is changed (i.e. a different version to yours), then you abort the transaction and the user can re-start the ransaction with the new data and update appropriately.
Pessimistic locking is when you lock the record for your exclusive use until you have finished with it.There are 4 levels of locking in the pessimistic isolation levels from lowest to highest. They are:read uncommitted, read committed, repeatable read, and serializable. At the serializable level thehighest locking and isolation level) it has much better integrity than optimistic locking but requires you to be careful with your application design to avoid deadlocks.
Pessimistic locking is when you lock the record for your exclusive use until you have finished with it.There are 4 levels of locking in the pessimistic isolation levels from lowest to highest. They are:read uncommitted, read committed, repeatable read, and serializable. At the serializable level thehighest locking and isolation level) it has much better integrity than optimistic locking but requires you to be careful with your application design to avoid deadlocks.
Comment