Improve recovery from corrupt or unwritable History database.

Create new database when the existing one is corrupt.
Report error when database is read-only, but ignore otherwise.
Add scheduled events for pausing and resuming low, medium and high priority job groups.