liveBook · Manning

Durability

As explained in MongoDB 8.0 in Action, Third Edition

Data durability is the property that committed data remains recoverable after process termination or system failure.

Durability ensures that committed transaction data remains recoverable after power loss, crashes, process termination, or other system failures. It is one of the four ACID properties and protects applications from losing confirmed changes. section 8.3

MongoDB’s WiredTiger storage engine combines checkpoints with write-ahead journaling. The journal records modifications made since the last checkpoint; after an unexpected exit, WiredTiger replays those records to recover the changes. Journal entries use Snappy compression by default, configurable through storage.wiredTiger.engineConfig.journalCompressor. section 8.1.2

Durability choices involve operational trade-offs:

  • Use replication to preserve data accessibility when a server in a shard fails; each shard needs replicated copies to avoid temporary inaccessibility. section 9.0
  • Tune write concern, read concern, and read preference according to durability, consistency, performance, and availability requirements. section 9.5
  • Request { w: "majority" } for writes and use majority read concern when an application must reliably read its own writes from the primary. section 9.5

Recovering a booking transaction

A travel booking that reserves a flight and hotel should commit both changes or neither. If MongoDB exits after the commit but before the next checkpoint, WiredTiger uses its journal to replay modifications since that checkpoint, preserving the committed booking rather than leaving confirmed data lost or partially applied. section 8.0 section 8.1.2

How MongoDB 8.0 in Action, Third Edition covers it

How deep it goes
Defines durability through ACID, explains journal-and-checkpoint recovery, and extends treatment to replication and concern configuration.
Examples
Uses a flight-and-hotel booking, journal replay after an unexpected exit, replica failures, and majority concern settings.
What it assumes
Introduces ACID terminology while assuming basic awareness of MongoDB transactions, storage engines, replica sets, and sharded deployments.
What you can do after
Configure journaling-related storage settings, replication, and read/write concerns for application-specific durability and availability requirements.
How it connects
Connects durability to ACID transactions, WiredTiger, journaling, checkpoints, replication, sharding, and read/write concern.

Also explained in

Compare how 6 books explain durability →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of MongoDB 8.0 in Action, Third Edition. The section links point to the parts of the book it draws on.