Handle errors when compacting broken db. Refs #1062.
Merge pull request #1064 from mapbox/broken-db

Handle errors when compacting broken db. Refs #1062.