Storage: Directory Structure



On-disk Data Structure

  • The on-disk structure of RavenDB data directories is as follows:

  • <data-dir>
    • Databases
      • <database-name>
        • Confguration
          • Journals
          • Temp
          • Raven.voron
        • Indexes
          • <index-name>
            • Journals
            • Temp
            • Raven.voron
          • ...more indexes
        • Journals
        • Temp
        • Raven.voron
      • ...more databases
    • System
      • Journals
      • Temp
      • Raven.voron

  • The main <data-dir> contains:

    • Databases folder
      Contains subdirectories with data per database.
    • System folder
      Stores cluster data & server-wide data such as shared resources needed by all cluster nodes,
      e.g. the Database Record.
  • The System folder, the Database folders, and their inner folders (the Configuration folder and each Index folder) are each a separate Voron storage environment.

Voron Storage Environment

  • Each Voron storage environment is composed of:

Temp Folder

  • Holds temporary scratch & compression *.buffers files.
  • These are small memory-mapped files that keep separate data versions for concurrent running transactions.
  • Data modified by a transaction is copied into the scratch space - modifications are made on a copy of the data.
  • Compression files are used to compress the transaction data just before writing it to the journal.
  • When a transaction is written from these files to the journal file it is considered committed.

Journals Folder

  • Contains Write-Ahead Journal files (WAJ) that are used in the hot path of a transaction commit.
  • From the journals, transactions will be flushed to the Voron data file where they are persisted.

  • Entries written to these files use unbuffered sequential writes and direct I/O to ensure a direct write that bypasses all caches.
  • Writes to the journals happen immediately, have high priority, and take precedence over writes to the Voron data file.

  • Data is cleared from the journals once it is successfully stored in the Voron data file.
  • The journal's transactions take part in database recovery - info is used to recover up to the same point you were at before failure.

Raven.voron file

  • This file contains the persisted data on disk.
  • It is a memory-mapped data file using buffered writes with random reads and writes.