basho/bitcask — pull request #64 by slfritchie (2012-10-18 21:08:40+00:00)
Title: Gh62 badrecord mstate

Rather than squash commits, I wanted to leave all 5 parts as the are for easier review, if that's what the reviewer wishes.

1. Add an eunit test that exposes the bug.
2. Fix the bug.
3. Change behavior of CRC error: don't treat it as a fatal error, in hope that stuff later in the file (if any) are salvagable.
4. Refactor using "after" to consolidate file handle closing.
5. Fix the same bug elsewhere.

Item 3 is reasonable, I believe, though if a large part of a file has corruption, an unintended effect could be error message spam. However, for a large spam tsunami, I think you'd have to have corruption inside multiple objects but not affecting the inter-object headers ... which seems unlikely.

Item 4 makes the code a bit longer but is the pattern intended for try/catch/after use, which I hope shows clearer intent.