liveBook · Manning

Atomicity

As explained in Spring Start Here, Second Edition

Atomicity is the transaction property that requires all operations in a transaction to succeed together or for none of their changes to take effect.

Atomicity means that a transaction’s related data changes take effect together, or not at all. If all steps succeed, the transaction commits and stores the changes; if a step fails, a rollback restores the data to its state at the transaction’s start. section 13.0 section 13.1

A money transfer

A transfer withdraws money from one account and deposits it into another. Without atomicity, a failed deposit could leave the withdrawal in place and the accounts inconsistent. A transaction makes the two changes one unit: both persist, or neither does. section 13.1

Figure 13.3 A transaction solves possible inconsistencies that could appear if any of the steps of a use case fail. With a transaction, if any of the steps fail, the data is reverted to how it was at the transaction start.

Shows how a transaction reverts data to its starting state when a step fails. section 13.1

How Spring Start Here, Second Edition covers it

How deep it goes
Defines atomicity and explains commit and rollback through a two-step transfer, without developing implementation details.
Examples
Uses a transfer between two accounts to show how a failed deposit can leave money missing.
What you can do after
Understand how a transaction prevents a partial transfer from leaving accounts inconsistent.
How it connects
Connects atomicity with transactions, commit, rollback, and data consistency.

Also explained in

Compare how 19 books explain atomicity →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring Start Here, Second Edition. The section links point to the parts of the book it draws on.