Zotero 9. No longer able to open database ("Loading items...")

Hi,

I was upgraded to Zotero 9 and can no longer access my data. I waiting at "loading items" for 10-15 minutes. I restarted in troubleshooting mode. waited. I restarted in troubleshooting mode with logging enabled, waited. I downloaded and installed the latest version, just in case... repeated the above processes.

It has been a couple hours now without access to my data, which is a little frustrating given that I have deadlines approaching.

here is the debug ID. D1768391229

From looking at the logs it doesn't seem like there is a migration going on, or anything that should take a particularly long time.

thanks.
  • dstillman Zotero Team
    Error: 'annotation' not loaded for item (3633/1/2RCGRA3J)

    Zotero.Exception.UnloadedDataException@chrome://zotero/content/xpcom/error.js:158:16
    Zotero.DataObject.prototype._requireData@chrome://zotero/content/xpcom/data/dataObject.js:716:11
    get@chrome://zotero/content/xpcom/data/item.js:4205:12
    Zotero.Item.prototype.updateDisplayTitle@chrome://zotero/content/xpcom/data/item.js:999:52
    Zotero.Items</this._loadItemData@chrome://zotero/content/xpcom/data/items.js:320:16
    Check your database integrity from the Advanced → Files and Folders pane of the Zotero settings. Does it pass?
  • Hi,

    Thanks for the prompt reply. I have run the integrity check, it says that the database is corrupt and Zotero can attempt to repair it. I asked it to do that... button greys out for a while. Then it comes back, but Zotero doesn't automatically restart (I thought it would?). I run the check again, same thing. I restart Zotero, run check again, and... same thing.

    The "loading items" issue is, of course, still there. How do I fix the database?


    thanks,
  • dstillman Zotero Team
    You have an invalid row in your database. Could be from a plugin or some previous bug. (I think you would've been upgrading from Zotero 7?)

    We'll fix the startup hang, but for now, you can go to Tools → Developer → Run JavaScript and run this to fix your database:

    await Zotero.DB.queryAsync("DELETE FROM items WHERE itemTypeID=(SELECT itemTypeID FROM itemTypes WHERE typeName='annotation') AND itemID NOT IN (SELECT itemID FROM itemAnnotations)");

    Then restart Zotero.
  • dstillman Zotero Team
    But if your database still shows as corrupted after running that, you may run into other problems in the future. Can you provide a Debug ID for running the integrity check?
  • FIXED

    Thanks, it was the db integrity. I had Claude Code examine a copy of the database and there were a number of internal inconsistencies. Most stemmed from a sync that seems to have failed partway through, created a load of entries but never populated them.

    Claude deleted the items (15 of them) and now Zotero works fine.

    Thanks for the help.
  • dstillman Zotero Team
    OK, but note that you should never make direct changes to the database yourself, and that includes with AI. I gave you the specific command above to fix this particular error, and the DB integrity check should've fixed others. If it didn't, that's something we'd want to debug so that it could be fixed in an automated way for everyone.
  • I'm afraid I did not see your comments before I had already gone off to fix it. I had no idea how long I would have to wait, so I had claude look at it to see if it could figure out the problem.

    I created a backup, and then had claude work on a copy. I reviewed the commands before running them, and they seemed fine. If they caused a problem, I could simply revert to the backup.

    On the issue causing the problem re: not loading.

    Claude: "The problem is logical/referential inconsistency: 15 rows in the items table are typed as annotations (itemTypeID = 1) but have no matching row in itemAnnotations"

    -- BACKUP FIRST: cp zotero.sqlite zotero.sqlite.bak
    BEGIN;
    DELETE FROM items
    WHERE itemTypeID = 1
    AND itemID NOT IN (SELECT itemID FROM itemAnnotations);
    -- verify: should be 15
    SELECT changes();
    COMMIT;

    Second problem:

    Claude: "PRAGMA foreign_key_check reports pre-existing inconsistencies that are not caused by this fix — 6 rows in itemRelations referencing missing items (774, 782, 827, 866, 876, 992), 1 row in deletedItems (1958), and a large number of rows in fulltextItemWords."

    The issue here is that, I did attempt the "fix database" route, but I didn't restart zotero and check to see if the error remained.

    Instead I had claude fix the db, then shutdown zotero and installed the fixed one, and reran the check and it passed.

    I have a backup of the broken foreign key version, I can install that, do the check, restart and do the check again. But since it was just an FK issue I assume it would be covered by the existing code.


    thanks.

Sign In or Register to comment.