Consistency checker

You can use the neo4j-admin database check command to check the consistency of a database, a dump, or a backup. The neo4j-admin tool is located in the /bin directory. If checking the consistency of a database, note that it has to be stopped first or else the consistency check will result in an error.

It is not recommended to use an NFS to check the consistency of a database, a dump, or a backup as this slows the process down significantly.

Syntax

The neo4j-admin database check command has the following syntax:

neo4j-admin database check [-h]
                           [--expand-commands]
                           [--force]
                           [--verbose]
                           [--check-counts[=true|false]]
                           [--check-graph[=true|false]]
                           [--check-indexes[=true|false]]
                           [--check-property-owners[=true|false]]
                           [--additional-config=<file>]
                           [--max-off-heap-memory=<size>]
                           [--report-path=<path>]
                           [--threads=<number of threads>]
                           [[--from-path-data=<path> --from-path-txn=<path>] | [--from-path=<path> [--temp-path=<path>]]]
                           <database>

<database> — Name of the database to check.

Options

The neo4j-admin database check command has the following options:

Option Possible values Description

-h, --help

Show this help message and exit.

--expand-commands

Allow command expansion in config value evaluation.

--force

true or false (Default: false)

Force a consistency check to be run, despite resources, and may run a more thorough check.

--verbose

true or false (Default: false)

Enable verbose output.

--check-graph

true or false (Default: true)

Perform checks between nodes, relationships, properties, types, and tokens.

--check-counts

true or false

Perform consistency checks on the counts. Requires the check-graph option to be true (which is by default) and will implicitly enable <check-graph> if it is not explicitly disabled. Default: <check-graph>.

--check-indexes

true or false (Default: true)

Perform checks on indexes.

--check-property-owners

true or false (Default: false)

Perform consistency checks on the ownership of properties. Requires the check-graph option to be true (which is by default) and will implicitly enable <check-graph> if it is not explicitly disabled.

--additional-config

<file>

Path to a configuration file that contains additional configuration options.

--max-off-heap-memory

<size> (Default: 90%)

Maximum memory that neo4j-admin` can use for page cache and various caching data structures to improve performance. Value can be plain numbers, like 10000000 or e.g. 20G for 20 gigabytes, or even e.g. 70%, which will amount to 70% of currently free memory on the machine.

--report-path

<path> (Default: .)

Path to where a consistency report will be written. Interpreted as a directory, unless it has an extension of .report.

--threads

<number of threads> (Default: the number of CPUs on the machine)

Number of threads used to check the consistency.

--from-path-data

<path> (Default: server.directories.data/databases)

Path to the databases directory, containing the database directory to source from.

--from-path-txn

Path to the transactions_ directory, containing the transaction directory for the database to source from.

--from-path

<path>

Path to the directory containing dump/backup artifacts whose consistency will be checked.

--temp-path

<path>

Path to a directory to be used as a staging area to extract dump/backup artifacts if needed.

<database>

Name of the database to check.

Output

If the consistency checker does not find errors, it exits cleanly and does not produce a report. If the consistency checker finds errors, it exits with an exit code other than 0 and writes a report file with a name in the format inconsistencies-YYYY-MM-DD.HH24.MI.SS.report. The location of the report file is the current working directory, or as specified by the parameter report-path.

Example

Example 1. Run the consistency checker

Note that the database must be stopped first.

$neo4j-home> bin/neo4j-admin database check neo4j

Running consistency check with max off-heap:618.6MiB
  Store size:160.0KiB
  Allocated page cache:160.0KiB
  Off-heap memory for caching:618.5MiB
ID Generator consistency check
....................  10%
....................  20%
....................  30%
....................  40%
....................  50%
....................  60%
....................  70%
....................  80%
....................  90%
.................... 100%
Index structure consistency check
....................  10%
....................  20%
....................  30%
....................  40%
....................  50%
....................  60%
....................  70%
....................  80%
....................  90%
.................... 100%
Consistency check
....................  10%
....................  20%
....................  30%
....................  40%
....................  50%
....................  60%
....................  70%
....................  80%
....................  90%
.................... 100%

Run with the --from-path option to check the consistency of a backup or a dump.

bin/neo4j-admin database check --from-path=<directory-with-backup-or-dump> neo4j

neo4j-admin database check cannot be applied to composite databases. It must be run directly on the databases that are part of a composite database.