What are pessimistic and optimistic lock s ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Guest

    What are pessimistic and optimistic lock s ?

    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.
  • Guest

    #2
    In pessimistic locking, the object is locked when it is initially accessed for the first time in a given transaction. ... In optimistic locking, the object is not locked when it is accessed for the first time in the transaction. Instead, its state (generally the version number) is saved.

    Comment

    Working...
    😀
    😂
    🥰
    😘
    🤢
    😎
    😞
    😡
    👍
    👎