Yes, you're quite right that it was a corrupted database. Luckily for me, simply knowing which directories stuff is kept in allowed me to restore stuff from a couple of days ago with TimeMacihne and it appears to be happy now.
That is a seriously scary thing to go wrong.