Open unkaktus opened 6 years ago
Sorry about your corrupted Elvish db... The panic sounds like a Bolt bug though; here is a similar one.
@xiaq, is it a good idea to back up the database at some point? Of course it would be nice not to have this kind of bug at all but still... :wink:
Just for the record, this happened to me today. Discussed on chat. I had the db on an nfs mounted home directory, and carelessly (?) worked on several machines with the same home directory simultaneously. Boom, corrupted db file.
FYI, boltdb is not network filesystem safe. See https://github.com/boltdb/bolt/issues/690. I don't see any issues in the bbolt fork elvish uses that mention NFS or other shared file systems. So it seems reasonable to conclude that the boltdb used by elvish is still not safe to use when the home directory is on NFS (or other shared file systems such as Dropbox). This is another good reason to move the elvish interactive database out of ~/.elvish as proposed by the XDG Base Specification issue.
FWIW, I got tired of Dropbox creating "conflicted copy" versions of my ~/.elvish/db file.
I am surprised this invalid sharing of a mmap'd file, treated as a key:value store, hasn't caused me to notice history corruption. It appears to be a fortuitous intersection of Elvish, UNIX and Dropbox file semantics.
So I ran
> mkdir ~/.local/share/elvish
> cd ~/.elvish
> ln -s ~/.local/share/elvish/db db
That example is obviously incomplete, and unique to my situation, but illustrates how some Elvish users might deal with this issue. It would be nice if Elvish defaulted to storing its interactive command history in a file in a directory unrelated to its config files.
Due to power loss my elvish boltdb got corrupted, so elvish panics with:
It would be definitely great to display some error message like
corrupted database
.