Handle database errors during rescans better