# Consistency checker
# How do you run it?
It is part of immudb, enabled by default and runs as a thread of immudb. The routine can be disabled as follows:
# What does it check?
Consistency checker runs in a loop and continuously checks if the elements stored inside the immudb Merkle-tree are also physically stored correctly on the disk (the digest of the disk elements is the same digest stored in the related Merkle-tree leaf)
# How does it run its check?
- reading the last root and last index stored in immudb
- generate a range between 0 and the length of the Merkle-tree level 0 (total number of elements stored)
- shuffles the range to get a random scan list (to be unpredictable)
- check if every element is correctly inserted in the Merkle-tree and if the Merkle-tree leaves correctly represent the elements stored on hard disk
- after completing the loop, the process sleeps ten seconds and restarts from scratch with a new root and index
- in case an element does not pass the check correctly, immudb is immediately stopped and prints out a log message
In order to produce a corrupted entry that is only on disk and not in the Merkle-tree, stop the immudb process and use the nimmu command:
go build tools/nimmu/nimmu.go ./nimmu rawset key1 tamper
Then restart immudb and should see the consistency check printing an error.