Close the tmp db before renaming.