Explicit Locks


Last Updated on Feb 17, 2021

When performing Read-Modify-Write operation, there is a danger that a concurrent transaction can read the value to be updated in the background. The other transaction can end up making incorrect decisions, or at worst, overwriting the data.

It is best to avoid other transactions from peeking into an object's value in the middle of a read-modify-write operation. One can lock objects (or rows) for the duration of the operation with Explicit Locks. Transactions that try to read the value will then have to wait until the read-modify-write process is completed.

These explicit locks are convenient when the database does not support atomic operations or when the business logic handles more than an atomic update (usually the situation in most use cases).


© 2022 Ambitious Systems. All Rights Reserved.