Site is back up. The database server had a failed fan and two bad sticks of RAM that were replaced.
It took a long time to diagnose because at first it appeared that the database server was overloaded and stuck at 100% CPU usage. Normally when that happens it means the site is under heavy load because of bots or scrapers. I spent a long time trying to reduce bot traffic until I finally figured out it was actually bad RAM. I'm still not sure how exactly bad RAM led to 100% CPU usage.
This was probably also the source of the random "The database is unavailable" errors over the past weeks. This tended to happen when the automatic database backups ran. It was probably triggering the bad RAM and causing the database to crash and restart. It was hard to diagnose because I never suspected bad RAM could be the issue.