Skip to content

Journaling and Recovery

Mauricio David edited this page Aug 27, 2017 · 8 revisions

LiteDB is an ACID (Atomicity, Consistency, Isolation, Durability) database, so your data operations are always consistent across concurrency access.

Journaling

In v4, there is no more external journal file. Dirty pages are saved first in extended area on same data file, but after ends used position. With this change, LiteDB runs faster because there are no 2 files to open/lock/close. Working with a single file is better than works with two.

To guarantee data integrity and fail tolerance, LiteDB use this extended area in your file to write all changes before write on right data position.

Journaling is enabled by default. You can disable on string connection to get a fast write operations with some risk!

var db = new LiteDatabase("filename=mydata.db; journal=false");

Recovery

When engine are writing pages into disk, datafile are not integrity. If any problem occurs during this write operation, in next access database engine must do recovery process to back to last integrity state (before starts writing). This process uses journal pages written in same disk after used area. After restore this pages to original position (backing disk to original state before stat writing) this extended area are shrinked.