TLDR: Decoding Atomicity - The A in ACID
Date: 2021-07-02 Source: https://arpitbhayani.me/blogs/atomicity
Overview
Understand Atomicity (the "A" in ACID) in databases, file systems, and hardware. Learn how it ensures data integrity and prevents partial updates. In this short essay, we dive deep and understand the “A” of ACID - Atomicity.
Key Points
- In this short essay, we dive deep and understand the “A” of ACID - Atomicity.
- Atomicity in Databases: Most databases implement Atomicty using logging; the engine logs all the changes and notes when the transaction started and finished.
- Atomicity in File Systems: At the file system level, atomicity is attained by atomically opening and locking the file using system calls: open and flock.
- Atomicity at Hardware Level: At the hardware level, atomicity is implemented through instructions such as Test-and-set, Fetch-and-add, Compare-and-swap.
- The construct of atomicity can be implemented at a high-level language or business logic by burrowing the concept of atomic instructions; for example, you can use compare and swap to update the value of a variable shared across threads concurrently.