Durability errors

Errors

  1. Snapshot or WAL directory don’t exist, there is nothing to recover. For more details, visit: memgr.ph/durability.
  2. No snapshot or WAL file found. For more details, visit: memgr.ph/durability.
  3. Couldn’t get WAL file info from the WAL directory. For more details, visit: memgr.ph/durability.

Why are snapshot and WAL files missing?

There are two options:

  1. The files are missing because Docker doesn’t store them.
  2. Memgraph is looking in the wrong directory.

Docker not persisting data

It’s possible that your Docker containers don’t persist data by default (all changes are lost when the container is stopped). You need to use local volumes to store the data permanently which is why Memgraph is started with the -v flag:

docker run -p 7687:7687 -v mg_lib:/var/lib/memgraph memgraph/memgraph

More information on Docker Volumes can be found here.

Memgraph data directory not set correctly

Make sure that Memgraph is searching for the snapshot files in the right directory. The Memgraph configuration is available in /etc/memgraph/memgraph.conf and you can specify the directory with the --data-directory flag. If the configuration file is altered, Memgraph needs to be restarted. The default directory is /var/lib/memgraph. To learn about all the configuration options, check out the reference guide.

Why doesn’t Memgraph start after a recovery failure?

On startup, Memgraph recovers each database from its snapshot and WAL files. If a snapshot or WAL file it needs for recovery can’t be loaded, usually because a disk issue damaged it, recovery stops and Memgraph doesn’t start. WAL files that the newest snapshot already covers aren’t read, so damage in them doesn’t stop recovery.

To start the instance and recover the database:

  1. Restart Memgraph with --storage-allow-recovery-failure=true. The database that failed comes up empty, in a broken state, with its files left as they were. Other databases on the instance work normally.

  2. Switch to the broken database and load a good snapshot from its snapshots directory:

    USE DATABASE DATABASE_NAME;
    RECOVER SNAPSHOT "SNAPSHOT_PATH";

    DATABASE_NAME is the database that failed (memgraph by default), and SNAPSHOT_PATH is the full path to the snapshot file. In Memgraph Community, skip USE DATABASE.

The database then holds only the data in that snapshot. Changes made after the snapshot was taken, including those in the damaged WAL file, are lost. If you have a backup of the whole data directory, you can restore it instead.

The --storage-allow-recovery-failure flag works only with in-memory storage modes. For details, see recovery failure handling.