How Punchagan Lost His Elfeed Database

A couple of weeks ago, I wrote about how Punchagan over at NOETIC NOUGHT started saving his Elfeed database after he lost it in a system crash. At the time, Punchagan didn’t know exactly what happened, only that the system crashed and he lost his Elfeed database. He wasn’t even sure that the two events were related, only that they occurred at the same time. His solution to the problem was to set up periodic saving of his Elfeed data to git.

A little later he had some time to troubleshoot the problem and discovered what happened. The Elfeed database is basically a hash table and saving it is simply a matter of dumping the binary to a file. This happens inside a with-temp-file macro, which is much like the more familiar with-temp-buffer macro except that it saves the results to a file at the end. The saving is done with write-region, which first truncates any existing file.

What happened, apparently, is that the system crashed between the truncation of the old file and writing the new file. Sadly there’s not much that can be done at the user level other than saving the file periodically.

I liked this post because it shows how easy it is to simply follow the code—which is, of course, available whenever you’re running Emacs—to see what’s happening. Emacs, to be sure, has more sophisticated tools for debugging but often simply looking at the code will reveal what’s going on. Punchagan’s post reminds me of Sacha Chua’s post on figuring out how to edit an SVG file and its source at the same time. She figured out how to do this the same way as Punchagan solved his problem: by reading the source code to see where the undesirable behavior was happening.

This entry was posted in General and tagged , . Bookmark the permalink.