Fix an assert that can fail if the database file is corrupted.
Version 3.8.6
Merge the 3.8.6 release into the threads branch.