Show TOC

Background documentationOptimistic Lock Conflicts Locate this document in the navigation structure

 

In conflicts, an optimistic lock (lock mode O) behaves like a shared lock (type Shared), which means it conflicts with type E or type X locks.

More information: Lock Collisions

If an exclusive lock belonging to another owner exists, the optimistic lock cannot be set. It is irrelevant whether the exclusive lock is a conventional E lock or a converted optimistic lock.

An existing optimistic lock also prevents other owners from receiving an E or an X lock directly.

The graphic below shows the case where an optimistic lock cannot be set, because an exclusive lock is already set on the object.

This graphic is explained in the accompanying text.

Conflict when Setting the O Lock

Optimistic locks belonging to different owners are compatible with one another. The first owner who tries to convert an optimistic lock into an exclusive lock can do so successfully (provided no other normal shared locks are set). The other optimistic locks become invalidated (deleted from the lock table). If you try to change them, the exclusive lock cannot be set.

You see this on the screen as shown in the figure below: Transaction 1 transforms the optimistic lock into an E lock. This makes the O lock of transaction 2 (which locks the same object) invalid. This means that transaction 2 cannot transform the O lock and the conflict must be resolved by the programmer.

This graphic is explained in the accompanying text.

Optimistic lock cannot be transformed