You are currently browsing legacy 4.1 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Storage: Transaction Mode

Voron storage engine can work in one of the following transactions modes: Safe, Lazy or Danger.

Safe

By default, Voron uses Safe mode. Transactions are written to journal files first (unbuffered I/O, write-through), and only afterwards copied to the data file. The journals, functioning as the transactions log, are stored to preserve the durability property of ACID transactions. In the event of non graceful server shutdowns, the journals are the source of the recovery mechanism which happens on the next database startup.

Each transaction is written to the journal once it's committed and it can be easily recovered if necessary. The user gets successful response only if the commit finishes successfully.

Lazy

Lazy mode tells Voron to store transactions in temporary memory mapped journal files, which means the data is not written to the disk on the transaction commit. It happens only when the journal is full (256 MB in 64 bit / 32 MB in 32 bit) and a new journal needs to be opened. The previous one is flushed into the data file. By storing the journals directly into memory, we gain speed, but there is a chance to lose the latest transactions.

Danger

Danger mode as it sounds is dangerous to use. It means data will be written to the disk with bypassing the machine and disk memory buffers. In the event of non graceful shutdown, the journal file might get corrupted. The data in the journal might enter inconsistent and non recoverable state.

The benefit is, therefore, speed over data integrity in case of Danger mode and speed with the price of possible transactions lose in Lazy mode.

Changing Transaction Mode

You can set the transaction mode for a database by using the following endpoint:

{server-url}/databases/{database-name}/admin/transactions-mode&mode=< Safe | Lazy | Danger >

If Lazy or Danger is set and not changed explicitly within 24 hours, RavenDB will automatically return to Safe mode. You can control the duration of a database working in non safe mode by using the Storage.TransactionsModeDurationInMin configuration option.

Example

curl -X GET http://127.0.0.1:8080/databases/myDB/admin/transactions-mode?mode=Safe