Tokyo Cabinet Database Recovery
Even if you don’t hit this ugly issue, non-transactional Tokyo Cabinet is not crash safe. Toru Maesaka took the time to document the recovery process:
confirming that the database is broken by using the command line tools:
Look at the “additional flags” line on the output of
tchmgr informortcbmgr informdepending on your database type. If it says, “fetal” then your file is really broken. If it says “open”, it means that your application died or exited without closing the database. A file in the “open” state is still usable but your most recent records are most likely unavailable.Note: Even if I wish you’ll never have to see it, I really hope that the term is “fatal” (instead of “fetal”).
use Tokyo Cabinet API
- open the database file without the lock option
- run
tchdboptimize()ortcbdboptimize()
[…] If you’re lucky, the above would repair the database that is associated with TC’s database object.
Note: the last sentence doesn’t sound too encouraging.
use Tokyo Cabinet command line tool (alternative solution)
TC provides a utility program called
tchmgr(for a hash database) andtcbmgr(for a b+tree database) which allows you to run optimize on a database file.
Having in mind that the main developer of Tokyo Cabinet is already working on the Tokyo Cabinet successor, I really hope for two things:
- somebody will translate the Tokyo Cabinet documentation in English
- the Tokyo Cabinet successor will have both better tools and better documentation.
via: http://torum.net/2010/01/how-to-recover-a-tokyo-cabinet-database-file/