Skip to content

Optimistic locking

Optimistic locking detects on save whether a record has changed since the version that was read.

Software Development

Compare the starting state when saving

Optimistic locking checks during a change whether the known record state still applies. A version identifier often provides the comparison value. In a fictional example, two people edit the same service address. After the first save, the second must not silently overwrite the changed state.

The version condition and write must be enforced reliably together. An earlier comparison followed by an unprotected write is insufficient. No long editing lock is held while a user enters data, although short locks may still occur during the database write. A detected conflict needs a business resolution, such as rereading and reviewing changes. The mechanism does not decide which input is correct.

Sources

Articles on this topic

Software Development with ASES

Custom software, web and mobile apps