Remove database lock after crash

My computer just crashed while firefox and zotero were opened. I had to remove firefox lock files manually before I could run firefox. However, zotero is not working yet: "Your zotero database is currently in use". How can I remove this lock?

I think this issue can be reproduces by sending a kill -9 signal to firefox, while zotero is opened.
  • edited April 22, 2013
    Deleting the zotero.sqlite-journal file in your Zotero data directory might do it, though I would expect that to be cleaned up automatically, since that's one of the main points of the journal. (Or maybe that doesn't happen in the exclusive locking mode that we use, but I would expect many more reports of this if that were the case.) Just to be safe, you might want to verify with lsof that the database isn't actually still in use somehow (or you could just restart your computer).
  • Thank you for your fast reply. However, deleting zotero.sqlite-journal does not solve the problem, after restarting firefox zotero is still showing the same message.
  • edited April 22, 2013
    Have you restarted your computer?
  • edited April 22, 2013
    (And since that didn't help, I would restore the journal file for now.)
  • I have restared my computer, but it still doesn't work.

    How can I restore the journal file?
  • How can I restore the journal file?
    If you deleted it permanently, you can't. I meant if you deleted it through the GUI and still had it in the trash. In any case, probably doesn't matter.

    I don't know that we've ever seen this, but you could try uploading your database to the DB Repair Tool, or rebuilding it yourself with the manual instructions, assuming the SQLite command-line client can open it.

    But probably you should just restore from the last automatic backup, depending on when it's from. If you're using syncing that would then just pull down any data modified since that backup.

    Obviously, you should have a backup of your entire Zotero data directory before doing anything here.
  • edited April 22, 2013
    The problem was that the sqlite database was locked. It was mounted via NFS. Clearing the lock state of a file on a NFS mount can cause problems. This is explained here: http://stackoverflow.com/a/1027493

    Removeing the journal file is a bad idea, as this journal file can be used to recover the database. I removed the filesystem lock by moveing the file, and then copying it back:
    mv zotero.sqlite zotero.sqlite.old; cp zotero.sqlite.old zotero.sqlite
    I used sqlite3 to recover the databae and to check if the database is unlocked again:
    sqlite3 zotero.sqlite .tables
  • Ah, OK, this being on an NFS share is a fairly important detail. You can easily run into problems when using SQLite over network shares.

    (And yes, removing -journal is absolutely a bad idea, but if this hadn't been a network share there wouldn't really have been anything else to try.)
Sign In or Register to comment.