-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Journaling and Recovery
This documentation is valid only for
v4.x
version.
LiteDB is an ACID (Atomicity, Consistency, Isolation, Durability) database, so your data operations are always consistent across concurrent read/write operations.
In v4, there is no more external journal file. Dirty pages are first saved in an extended area in the same data file, but past the end of the main data pages. With this change, LiteDB runs faster because there are no longer 2 files to open/lock/close. Working with a single file is better than working with two.
To guarantee data integrity and fault tolerance, LiteDB uses this extended area in your database file to write all changes before writing to the target location.
Journaling is enabled by default. You can disable it in the string connection for faster write operations but with some risk!
var db = new LiteDatabase("filename=mydata.db; journal=false");
While the engine is writing pages to disk the datafile's integrity is compromised. If any problem occurs during this write operation the database engine will run a recovery process when the datafile is next accessed. This brings the datafile back to its last good state (before the failed write operation). This process uses journal pages written in the same datafile after the used area. After these pages are restored to their original position, and so the datafile is restored, then this extended area is shrunk.
Data Modeling
- Data Structure
- BsonDocument
- Object Mapping
- Relationships with Document References
- Collections
- FileStorage
Index
Query
Database
Version 4 changes
Shell