Q44: How does Journaling work in MongoDB?

Journaling writes changes to an on-disk write-ahead log file before updating actual database files. If MongoDB shuts down unexpectedly or crashes, the server replays the journal log during restart to restore the dataset to a consistent state without data corruption.

Key Takeaways
  • Write-ahead logging for crash recovery.

  • Journal commits occur every 50ms by default.

Knowledge Check

What primary protection does Journaling provide in MongoDB?