Table of Contents

About

An atomic action is one that effectively happens all at once.

  • An atomic action cannot stop in the middle: it either happens completely, or it doesn't happen at all.
  • No side effects of an atomic action are visible until the action is complete.

Example

An example of atomicity is ordering an airline ticket where two actions are required: payment, and a seat reservation. The potential passenger must either:

  • both pay for and reserve a seat; OR
  • neither pay for nor reserve a seat.

Domain

Transaction

In the context of a transaction , either all the tasks in a transaction must happen, or none of them. The transaction must be completed, or else it must be undone (rolled back).

This functionality is known as atomic commit.

Code

See Data Concurrency - Atomic Variable Access

File System

A file deletion should be atomic.

If a request to delete a file is send to the file system and the power is lost during the delete operation, once power is restored either:

  • the file will exist completely with all if its original content unaltered,
  • or else the file will not be seen in the filesystem at all.

If after power is restored the file is only partially deleted, if some of its data has been altered or erased, or the file has been truncated but not completely removed, then data corruption/inconsistency will likely result.

Documentation / Reference