Atomicity

Learn about the implementation of the atomicity guarantee in ACID transactions.

Introduction

Atomicity is one of the ACID properties of the database. Atomicity ensures the database executes a sequence of operations as one logical unit of work. The database either executes all the operations successfully or rolls back all the operations undoing the changes.

  • The act of successfully executing all the database operations is called a commit.

  • Reverting all the database operations on failure is called a rollback.

Atomicity ensures that the database does not end up with partially corrupted data on failures. This guarantee ensures that application developers can safely retry the transaction on failures.

Shadow copy

Shadow copy is one of the implementations of atomicity guarantee in a transaction.

Implementation

In the shadow copy implementation, every transaction that wants to change the database content creates a new copy of the database file. Then the database updates the new copy of the file. The old copy of the database is called a shadow copy.

A database pointer decides whether the transaction is committed or aborted:

  • The database pointer points to the old copy when the transaction is in progress.

  • The database pointer switches to point to the new copy when the transaction commits.

Get hands-on with 1200+ tech skills courses.