Atomic Writes
Last Updated on Feb 17, 2021
Applications that update changes in Read-Modify-Write cycles run the risk of losing updates when two transactions concurrently update the same value in the database.
Many databases provide atomic update operations to avoid this data loss. The data update is wholly processed within the database when written atomically. Atomic operations are usually implemented either with exclusive locks on the object when it is read or by forcing all atomic operations to be executed on a single thread.
If the write operation can be expressed in terms of atomic operations, it is almost always better to depend on the database to update values atomically.