Improve recovery from corrupted cache file

- add a simple query during initialization to have the DB bail out if it
was corrupted
- don't try to wipe the DB, delete the file instead and start from
scratch
- set up error handler to log the db file causing problems