Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Check leveldb cache store directory from the backup using a leveldb client.
    1. Verify the leveldb opens.
    2. Verify by iterating through the keys. (To expose any corruption)
  2. Based on the flow of the background compaction process in the leveldb implementation ([1] and [2]), the manifest file is updated at the end of compaction, which is followed by the deletion of obsolete files. To verify successful backups, we can begin the backup with copying the manifest file followed by the rest of the files. And, at the end of the backup, the backed up manifest file can be compared with the current manifest. An unchanged manifest can be considered as a successful backup, and vice versa.


    [1] https://github.com/google/leveldb/blob/master/db/db_impl.cc#L655
    [2] https://github.com/google/leveldb/blob/master/db/version_set.cc#L811

...

Repairing Corrupt LevelDB

The below script can be used to repair corrupt leveldb cache:

Code Block
languagepy
#!/usr/bin/python
import leveldb
import sys
import os

if (len(sys.argv) != 2) :
  print 'Usage:'
  print 'python repair.py /path/to/leveldb/cache'
  sys.exit(1)
path = sys.argv[1]
if not os.path.isdir(path) :
  print "Directory %s does not exist!" % path
  sys.exit()
leveldb.RepairDB(path)