Fossil: Database is locked

I’ve gotten the following error several times recently with my Fossil repo:

Database error: database is locked:

The message is followed by some details that may or may not make sense. The error has always occurred after a networking issue forced me to kill a commit operation. Here’s the solution that eventually worked for me. It might very well be a bad idea, but free internet content is worth what you pay for it:

  1. Make a backup of the repo. For instance, make a copy of the entire repo directory and name it repo-backup.fossil.
  2. Delete fslckout-journal in the original copy of the repo.

After that, things are back to normal. With any luck, it won’t completely destroy everything.

Update: That solution no longer works. What I do now is:

  1. Copy repo.fossil to a new directory. (Replace “repo” with the name of the repo as used in the file.)
  2. Open repo.fossil.
  3. Copy the changed files into that directory. (It’s easiest to copy all files if it’s a small repo.) That way you get all uncommitted changes to your files.
  4. Commit your changes.
  5. (Optional) Delete the old directory and rename the new directory with the old name.

This has been happening so often recently that I have been considering giving up on Fossil entirely and moving everything to Git. I’d hate to do that, but this is a serious usability issue that can pop up at any time, including just as I’m about to leave home/work. It’s not clear to me that this is always a networking issue either.

One side of this is that I can’t afford to have my files stuck on one machine. The repo gets messed and I don’t have time to deal with it.

The much bigger concern is that this is a bug that in the future will cause me to lose data. The main job of a version control system is the security it provides by automatically recording the entire history of the project and making it (as these things go) easy to recover that history when you need it. I can’t afford to find myself in a situation where I have only the most recent version of my files but I’ve lost the history of the project.

To be clear, I haven’t seen any evidence of this nightmare scenario. The repo is locking itself to prevent committing or pulling any changes. The ugly scenario plays out if I can’t figure out how to make the existing repo usable. If I can’t, that means I have to dump all the current versions of the files into a new repo, losing the history of the project in the process.