Author Topic: Catalog broken after crash  (Read 4297 times)

Offline DavidHoffmanuk

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Catalog broken after crash
« on: April 08, 2021, 12:18:37 AM »
My Mac Pro 5,1, 10.14.6 crashed while it was ¾ through building a catalog with about 200k files. Trying to reopen the catalog gives me:

Unable to open catalog:
open_catalog failed: ["open_catalog: CILA::PROTO::RPCException/catalog_open_db failed: [\"catalog_open_db: Sequel::DatabaseConnectionError/SQLite3::CantOpenException: unable to open database file\"]"]

Tried a backup copy and got this:

Unable to open catalog:
open_catalog failed: ["open_catalog: CILA::PROTO::RPCException/catalog_open_db failed: [\"catalog_open_db: Sequel::DatabaseError/SQLite3::CorruptException: database disk image is malformed\"]"]

I've tried restarting, forgetting the catalog and relocating it but no luck. Is there anything I can do or do I need to scrap this catalog which has taken more than 2 days to get this far?

Thanks
David Hoffman
« Last Edit: April 08, 2021, 12:52:22 AM by DavidHoffmanuk »

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24756
    • View Profile
    • Camera Bits, Inc.
Re: Catalog broken after crash
« Reply #1 on: April 08, 2021, 09:17:47 AM »
David,

My Mac Pro 5,1, 10.14.6 crashed while it was ¾ through building a catalog with about 200k files. Trying to reopen the catalog gives me:

Unable to open catalog:
open_catalog failed: ["open_catalog: CILA::PROTO::RPCException/catalog_open_db failed: [\"catalog_open_db: Sequel::DatabaseConnectionError/SQLite3::CantOpenException: unable to open database file\"]"]

Tried a backup copy and got this:

Unable to open catalog:
open_catalog failed: ["open_catalog: CILA::PROTO::RPCException/catalog_open_db failed: [\"catalog_open_db: Sequel::DatabaseError/SQLite3::CorruptException: database disk image is malformed\"]"]

I've tried restarting, forgetting the catalog and relocating it but no luck. Is there anything I can do or do I need to scrap this catalog which has taken more than 2 days to get this far?

Could you please try this?

Open the Terminal application.  (Applications/Utilities/Terminal)
Type the following at the prompt:

cd

then press the space bar once.  Then in the Finder, find your catalog folder and drag and drop it onto the Terminal window.  Then activate the Terminal window by clicking on it (or pressing Command-Tab to switch to the Terminal application).  Then press enter/return.

At the next prompt, copy and paste the following, and press enter/return:

sqlite3 catalog.pmdb "pragma integrity_check"

Copy and paste the output in your reply to this message.

Thanks,

-Kirk

Offline DavidHoffmanuk

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: Catalog broken after crash
« Reply #2 on: April 09, 2021, 02:01:41 AM »
Thanks Kirk - I get this

[Mac-Pro:~] davidhoffman% cd /Volumes/Scratch/PM6+\ all\ files\ 210406
[Mac-Pro:/Volumes/Scratch/PM6+ all files 210406] davidhoffman% sqlite3 catalog.pmdb "pragma integrity_check"
Error: database disk image is malformed
[Mac-Pro:/Volumes/Scratch/PM6+ all files 210406] davidhoffman%

Which I hope is more helpful than it appears. If I can't recover this DB it's not a big deal but it's important to avoid it happening in the future. I've done little more than ingest existing files so I only lose time, not data. What does matter to me is getting to a point where I have a database of my 200k+ files which is reliable, searchable, sortable and open to metadata editing.

I don't know if this is connected but I'm having serious slowdown problems with all other catalogs I've made when the sort order is set to any of the numbered options in the dropdown. Cap time, mod time, name, col class & rating all work fine but the sort by{xxx} options are not useable.

If I have one of the sort by{xxx} options selected (eg sort by path) I get a "preloading metadata' progress percentage shown for perhaps 3-4 minutes followed by a sorting message. If I click out of PM while this is going on then when I click back into PM from another app the preloading/sorting is cancelled and begins again. That means that I can't use any other apps while waiting for the sort to complete.

Another aspect of this sort problem is that when I searched 3 active catalogs with a mix of formats this morning using the term NEF$ I got mostly xxx.nef files but also quite a few xxx.jpg files too. Possibly other formats as well but with >100k files I didn't check in detail.

Thanks
David

Offline DavidHoffmanuk

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: Catalog broken after crash
« Reply #3 on: April 09, 2021, 02:20:13 AM »
Here's a screenshot of the NEF$ search.
David

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24756
    • View Profile
    • Camera Bits, Inc.
Re: Catalog broken after crash
« Reply #4 on: April 09, 2021, 09:09:22 AM »
David,

Thanks Kirk - I get this

[Mac-Pro:~] davidhoffman% cd /Volumes/Scratch/PM6+\ all\ files\ 210406
[Mac-Pro:/Volumes/Scratch/PM6+ all files 210406] davidhoffman% sqlite3 catalog.pmdb "pragma integrity_check"
Error: database disk image is malformed
[Mac-Pro:/Volumes/Scratch/PM6+ all files 210406] davidhoffman%

You could try this to recover the database:

First quit Photo Mechanic Plus if it is running.
From within the same folder as the catalog:

mv catalog.pmdb catalog-bad.pmdb
sqlite3 catalog-bad.pmdb "vacuum into 'catalog.pmdb'"

Note the single-quotes around catalog.pmdb inside the double-quoted vacuum command.  You can simply copy and paste the commands and you should be fine.

Please reply with the output, if any.  If it succeeds there won't be any output but your catalog may start working again.

Which I hope is more helpful than it appears. If I can't recover this DB it's not a big deal but it's important to avoid it happening in the future. I've done little more than ingest existing files so I only lose time, not data. What does matter to me is getting to a point where I have a database of my 200k+ files which is reliable, searchable, sortable and open to metadata editing.

I don't know if this is connected but I'm having serious slowdown problems with all other catalogs I've made when the sort order is set to any of the numbered options in the dropdown. Cap time, mod time, name, col class & rating all work fine but the sort by{xxx} options are not useable.

If I have one of the sort by{xxx} options selected (eg sort by path) I get a "preloading metadata' progress percentage shown for perhaps 3-4 minutes followed by a sorting message. If I click out of PM while this is going on then when I click back into PM from another app the preloading/sorting is cancelled and begins again. That means that I can't use any other apps while waiting for the sort to complete.

All of the numbered (custom) sorts are done brute-force like a folder based contact sheet.  The sorting cannot be done by the catalog system.  So in order to do those searches based on variables, all of the metadata needs to be in-memory and then the variables are expanded and the resulting strings are sorted to produce the order of the custom sort.

You can minimize this problem by turning off the "Rescan on resume" checkbox in the Contact Sheet page of the Preferences dialog.  You will have to manually rescan your contact sheets when you see fit.

Another aspect of this sort problem is that when I searched 3 active catalogs with a mix of formats this morning using the term NEF$ I got mostly xxx.nef files but also quite a few xxx.jpg files too. Possibly other formats as well but with >100k files I didn't check in detail.

Searching in that way will check all of the default fields ending in NEF.  So it's entirely possible to have matches that aren't NEF files.  Suggestions:

1) Use the Browse tab and expand the File Type tree and click on "Nikon NRW (NNEF)".
2) Use the Filter tab and create a new filter and set its type to "File Type" and then click on "Nikon NRW (NNEF)".
3) Use the Search tab and enter: filetype NNEF
4) Use the Search tab and enter: filename NEF$

HTH,

-Kirk

Offline DavidHoffmanuk

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: Catalog broken after crash
« Reply #5 on: April 09, 2021, 09:22:31 AM »
The last time I knew my way around a command line interface was CP/M so I have probably got this wrong. Here's a paste

[Mac-Pro:~] davidhoffman% cd /Volumes/Scratch/PM6+\ all\ files\ 210406
[Mac-Pro:/Volumes/Scratch/PM6+ all files 210406] davidhoffman% mv catalog.pmdb catalog-bad.pmdb
[Mac-Pro:/Volumes/Scratch/PM6+ all files 210406] davidhoffman% sqlite3 catalog-bad.pmdb "vacuum into 'catalog.pmdb'"
Error: near "into": syntax error
[Mac-Pro:/Volumes/Scratch/PM6+ all files 210406] davidhoffman%

David

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24756
    • View Profile
    • Camera Bits, Inc.
Re: Catalog broken after crash
« Reply #6 on: April 09, 2021, 09:48:01 AM »
David,

The last time I knew my way around a command line interface was CP/M so I have probably got this wrong. Here's a paste

[Mac-Pro:~] davidhoffman% cd /Volumes/Scratch/PM6+\ all\ files\ 210406
[Mac-Pro:/Volumes/Scratch/PM6+ all files 210406] davidhoffman% mv catalog.pmdb catalog-bad.pmdb
[Mac-Pro:/Volumes/Scratch/PM6+ all files 210406] davidhoffman% sqlite3 catalog-bad.pmdb "vacuum into 'catalog.pmdb'"
Error: near "into": syntax error
[Mac-Pro:/Volumes/Scratch/PM6+ all files 210406] davidhoffman%

Try this instead:

cp -p catalog-bad.pmdb catalog.pmdb
sqlite3 catalog.pmdb "vacuum"

-Kirk

Offline DavidHoffmanuk

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: Catalog broken after crash
« Reply #7 on: April 09, 2021, 10:27:59 AM »
I think the commands worked but the DB is broken. I get:

Error: database disk image is malformed

I'm assuming that's fatal?

I think the lesson is for me to make multiple smaller catalogs. As I can search all at once that reduces the nuisance factor but I think it may give me a problem with updating metadata across a found set. But that's for another time. For now I'll take a look at your points re sorting and see where I get to.

David

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24756
    • View Profile
    • Camera Bits, Inc.
Re: Catalog broken after crash
« Reply #8 on: April 09, 2021, 10:52:29 AM »
David,

I think the commands worked but the DB is broken. I get:

Error: database disk image is malformed

I'm assuming that's fatal?

Was that the output of the command?

I think the lesson is for me to make multiple smaller catalogs. As I can search all at once that reduces the nuisance factor but I think it may give me a problem with updating metadata across a found set. But that's for another time. For now I'll take a look at your points re sorting and see where I get to.

It is not our intent to have anyone create smaller catalogs unless it suits them to do so (one for personal photos, one for professional photos, etc.).  You're nowhere near the limits of catalog size.

When your catalog got damaged, did you have a total system failure (system was rebooted) or was there some other circumstance?

-Kirk

Offline DavidHoffmanuk

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: Catalog broken after crash
« Reply #9 on: April 09, 2021, 11:16:46 AM »
Hi Kirk

It was a complete sudden shutdown. No panic warning or freezes, just a little click, instant black display and the power light off.

David

Offline DavidHoffmanuk

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: Catalog broken after crash
« Reply #10 on: April 09, 2021, 11:18:49 AM »
David,

I think the commands worked but the DB is broken. I get:

Error: database disk image is malformed

I'm assuming that's fatal?

Was that the output of the command?

Yes - that's the line following your 'vacuum' line in Terminal.

David

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24756
    • View Profile
    • Camera Bits, Inc.
Re: Catalog broken after crash
« Reply #11 on: April 09, 2021, 11:42:59 AM »
David,

It was a complete sudden shutdown. No panic warning or freezes, just a little click, instant black display and the power light off.

We expect that to be one of the few conditions that should corrupt a database (another being a failing disk with damaged sectors/blocks).

I don't suggest that you make several smaller catalogs to try and work around this issue.  If your system is spontaneously crashing like that then no size of catalog will truly help.  If it occurs again, I suggest getting your computer checked out by Apple.

-Kirk

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24756
    • View Profile
    • Camera Bits, Inc.
Re: Catalog broken after crash
« Reply #12 on: April 09, 2021, 11:43:45 AM »
David,

I think the commands worked but the DB is broken. I get:

Error: database disk image is malformed

I'm assuming that's fatal?

Was that the output of the command?

Yes - that's the line following your 'vacuum' line in Terminal.

OK, thanks.  Then there's nothing that can be done.

-Kirk