---
title: "How SQLite helps you do ACID"
description: "SQLite’s rollback journal provides atomicity, isolation, and durability by preserving database state before a transaction changes the main file. Without journaling, an interrupted 4KB page write could corrupt the database; the journal instead records original pages, then permits recovery if commit steps fail. A journal header stores a nonce, the database’s pre-transaction page count, sector size, and page size, while each page record includes its page number, a copy of prior contents, and a 32-bit checksum. The mode allows concurrent readers but makes writers wait for readers and blocks new readers, using SHARED, RESERVED, and PENDING filesystem locks. Its simplicity brings a concurrency bottleneck; WAL and wal2 provide better support for concurrent readers, which the post says will be covered next."
---

# How SQLite helps you do ACID

[Fly.io](https://yomu.fyi/company/fly-io) · Aug 10, 2022

**Type:** Explainer

## Summary

SQLite’s rollback journal provides atomicity, isolation, and durability by preserving database state before a transaction changes the main file. Without journaling, an interrupted 4KB page write could corrupt the database; the journal instead records original pages, then permits recovery if commit steps fail. A journal header stores a nonce, the database’s pre-transaction page count, sector size, and page size, while each page record includes its page number, a copy of prior contents, and a 32-bit checksum. The mode allows concurrent readers but makes writers wait for readers and blocks new readers, using SHARED, RESERVED, and PENDING filesystem locks. Its simplicity brings a concurrency bottleneck; WAL and wal2 provide better support for concurrent readers, which the post says will be covered next.

## Context

SQLite must ensure that transactions do not leave partially written pages, expose inconsistent views to readers, or fail to flush committed bytes to disk. The rollback journal addresses these atomicity, isolation, and durability requirements, while its locking behavior creates trade-offs for concurrent workloads.

## Approach / What changed

SQLite writes the pre-transaction database state to a rollback journal, including a header and page records with page numbers, original page contents, and checksums. It syncs the journal before commit and deletes it to complete the transaction; filesystem locks coordinate readers and writers.

## Takeaways

- The rollback journal stores original database pages before they are changed, allowing SQLite to restore the prior state if a transaction fails before commit.
- Rollback-journal mode permits multiple read-only transactions but allows only one write transaction and blocks new readers while that write completes.
- SQLite’s rollback journal can bottleneck concurrent applications because writes wait for readers; WAL and wal2 were introduced to improve support for concurrent readers.

**Tags:** [Databases](https://yomu.fyi/topic/databases), [SQLite](https://yomu.fyi/topic/sqlite)

- Source: [Fly.io](https://fly.io/blog/sqlite-internals-rollback-journal)
- Source URL: https://fly.io/blog/sqlite-internals-rollback-journal
- Ingested by Yomu: 2026-09-03T00:00:49.316Z

[Read original post](https://fly.io/blog/sqlite-internals-rollback-journal)
