All Topics  
Atomicity

 

   Email Print
   Bookmark   Link






 

Atomicity



 
 
In database system
Database system

A database system is a term that is typically used to encapsulate the constructs of a data model, database Management system and database.A database is an organised pool of logically-related data....
s, atomicity (or atomicness) is one of the ACID
Acid

An acid is traditionally considered any chemical compound that, when dissolved in water, gives a solution with a hydrogen ion Activity greater than in pure water, i.e....
 transaction
Database transaction

A database transaction comprises a unit of work performed within a database management system against a database, and treated in a coherent and reliable way independent of other transactions....
 properties. In an atomic transaction, a series of database operations either all occur, or nothing occurs. A guarantee of atomicity prevents updates to the database occurring only partially, which can cause greater problems than rejecting the whole series outright.

The etymology of the phrase originates in the Classical Greek concept of a fundamental and indivisible component; see atom
Atom

|-! bgcolor=gray | Properties|-||}The atom is a basic unit of matter consisting of a dense, central atomic nucleus surrounded by a electron cloud of electric charge electrons....
.

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






Discussion
Ask a question about 'Atomicity'
Start a new discussion about 'Atomicity'
Answer questions from other users
Full Discussion Forum



Encyclopedia


In database system
Database system

A database system is a term that is typically used to encapsulate the constructs of a data model, database Management system and database.A database is an organised pool of logically-related data....
s, atomicity (or atomicness) is one of the ACID
Acid

An acid is traditionally considered any chemical compound that, when dissolved in water, gives a solution with a hydrogen ion Activity greater than in pure water, i.e....
 transaction
Database transaction

A database transaction comprises a unit of work performed within a database management system against a database, and treated in a coherent and reliable way independent of other transactions....
 properties. In an atomic transaction, a series of database operations either all occur, or nothing occurs. A guarantee of atomicity prevents updates to the database occurring only partially, which can cause greater problems than rejecting the whole series outright.

The etymology of the phrase originates in the Classical Greek concept of a fundamental and indivisible component; see atom
Atom

|-! bgcolor=gray | Properties|-||}The atom is a basic unit of matter consisting of a dense, central atomic nucleus surrounded by a electron cloud of electric charge electrons....
.

An example of atomicity is ordering an airline ticket where two actions are required: payment, and a seat reservation. The potential passenger must either:
  1. both pay for and reserve a seat; OR
  2. neither pay for nor reserve a seat.
The booking system does not consider it acceptable for a customer to pay for a ticket without securing the seat, nor to reserve the seat without payment succeeding.

Orthogonality


Atomicity does not behave completely orthogonally
Orthogonality

In mathematics, two vectors are orthogonal if they are perpendicular, i.e., they form a right angle. The word comes from the Greek language ' , meaning "straight", and ' , meaning "angle"....
 with regard to the other ACID
Acid

An acid is traditionally considered any chemical compound that, when dissolved in water, gives a solution with a hydrogen ion Activity greater than in pure water, i.e....
 properties of the transactions. For example, isolation
Isolation (computer science)

In database systems, isolation is a property that defines how/when the changes made by one operation become visible to other concurrent operations....
 relies on atomicity to roll back changes in the event of isolation failures such as deadlock
Deadlock

A deadlock is a situation wherein two or more competing actions are waiting for the other to finish, and thus neither ever does. It is often seen in a paradox like 'the chicken or the egg'....
; consistency
Database consistency

In database systems, a consistent database transaction is one that does not violate any integrity constraints during its execution. If a transaction leaves the database in an illegal state, it is aborted and an error is reported....
 also relies on rollback in the event of a consistency-violation by an illegal transaction. Finally, atomicity itself relies on durability
Durability (computer science)

In database systems, durability is the ACID property which guarantees that database transactions that have committed will survive permanently.For example, if a flight booking reports that a seat has successfully been booked, then the seat will remain booked even if the system crashes....
 to ensure the atomicity of transactions even in the face of external failures.

As a result of this, failure to detect errors and manually roll back the enclosing transaction may cause failures of isolation and consistency.

Implementation


Typically, systems implement atomicity by providing some mechanism to indicate which transactions have started and which finished; or by keeping a copy of the data before any changes occurred. Several filesystems have developed methods for avoiding the need to keep multiple copies of data, using journaling (see journaling file system
Journaling file system

A journaling file system is a file system that logs changes to a journal before committing them to the main file system. Such file systems are less likely to become corrupted in the event of power failure or system crash....
). Many databases also support a commit-rollback mechanism aiding in the implementation of atomic transactions. Databases usually implement this using some form of logging/journaling to track changes. The system synchronizes the logs (often the metadata
Metadata

Metadata is "data about other data", of any sort in any media. An item of metadata may describe an individual datum, or content item, or a collection of data including multiple content items and hierarchical levels, for example a database schema....
) as necessary once the actual changes have successfully taken place. Afterwards, crash recovery simply ignores incomplete entries. Although implementations vary depending on factors such as concurrency issues, the principle of atomicity — i.e. complete success or complete failure — remain.

Ultimately, any application-level implementation relies on operating-system
Operating system

An operating system is an interface between hardware and applications; it is responsible for the management and coordination of activities and the sharing of the limited resources of the computer....
 functionality, which in turn makes use of specialized hardware to guarantee that an operation remains non-interruptible: either by software attempting to re-divert system resources (see pre-emptive multitasking) or by resource-unavailability (such as power-outages). For example, POSIX
POSIX

POSIX or "Portable Operating System Interface" is the collective name of a family of related standardizations specified by the Institute of Electrical and Electronics Engineers to define the application programming interface , along with shell and utilities interfaces for software compatible with variants of the Unix operating system, altho...
-compliant systems provide the open(2) system call
System call

In computing, a system call is the mechanism used by an application program to request service from the kernel based on the Monolithic_kernel or to system servers on operating systems based on the microkernel-structure....
 which allows applications to atomically open a file. Other popular system-calls that may assist in achieving atomic operations from userspace include mkdir(2), flock(2), fcntl(2), rasctl(2) (NetBSD re-startable sequences), semop(2), sem_wait(2), sem_post(2), fdatasync(2), fsync(2) and rename(2).

The hardware level requires atomic operations
Linearizability

In concurrent programming, an operation is atomic, or linearizable, if it appears to take effect instantaneously. Implementation details may be ignored by the user, except insofar as they affect performance....
 such as test-and-set
Test-and-set

In computer science, the test-and-set instruction is an instruction used to both test and write to a memory location as part of a single atomic operation....
 (TAS), and/or atomic increment/decrement operations. In their absence, or when necessary, raising the interrupt level to disable all possible interrupts (of hardware and software origin) may serve to implement the atomic synchronization function primitive
Primitive

Primitive is a subjective label used to imply that one thing is less "sophisticated" or less "advanced" than some other thing. Being a comparative word it is also relative in nature....
s. Systems often implement these low-level operations in machine language or in assembly language
Assembly language

An assembly language is a low-level language for programming computers. It implements a symbolic representation of the numeric machine codes and other constants needed to program a particular CPU architecture....
.

See also

  • Atomic operation
    Atomic operation

    An atomic operation in computer science refers to a set of Instruction s that can be combined so that they appear to the rest of the system to be a single operation with only two possible outcomes: success or failure....
  • Transaction processing
    Transaction processing

    In computer science, transaction processing is information processing that is divided into individual, indivisible operations, called transactions. Each transaction must succeed or fail as a complete unit; it cannot remain in an intermediate state....