07 December 2024

The database that's behind one of my Photoprism instances took a dump.

 This is for all the Linux fanbois out there and whilst this isn't actually, technically, the fault of Linux -- considering the fact that said Linux fanbois will bitch about software that runs on Windows as if that's a Windows problem, therefore; this post is going to be similarly in that vain.


So, I've got a bunch of separate Photoprism instances running, where in the background, in the same docker-compose.yml file, it uses the MariaDB as the database backend. (Which is like some form of MySQL using the InnoDB engine. I don't really know much about it, so I'll just leave it at that.)


Anyways, for some inexplicable reason, the database took a dump and Photoprim stopped being able to communicate with it.


Found out that the database itself was corrupt, and then tried restarting the mariadb part of the docker-compose.yml file with --innodb-force-recovery=2 option (because when I tried to run it with --innodb-force-recovery=1, it was still producing a fatal 11 error). I also had to add --skip-grant-table to the command that's starting the mariadb because without it, not even the root user, from inside the container, can administer the database, which is very strange because normally, a root user should be able to do anything and everything.


When I tried to run mariadb-check --all-databases, it says:


photoprism.photos

Warrning: InnoDB: Index `idx_photos_checked_at` contains 1832435 entries, should be 1832246.

error: corrupt


And then I tried to run mariadb-check -f --all-databases and it said:


(for all of the photoprism.* tables)


note: The storage engine for the table doesn't support repair.


Anyways, long story short -- the database back end took a dump, so I ended up deleting the whole thing and my system is in the process of re-indexing anything so that it can rebuild the database.


Linux sucks.


*edit*

Yes, I did try to backup the database, drop the database, re-create the database, and then importing everything from backup.


The new error that I got with that was:


[Warning] failed to load slave replication state from table mysql.gtid_slave_pos: 1932: Table `mysql.gtid_slave_pos` doesn't exist in engine


I tried to quickly google how I can re-create it, but the SQL statements seemed awfully specific to the specific person who was asking that question, and so, I assumed that that may NOT necessarily be how that table needs to be defined for use by Photoprism. So, I just ended up deleting the entire database, and let it re-build said database from scratch, all over again. We'll see how that goes. What a colossal PITA it is, to try and fix/repair said database though.