DB Connection Check function and fixes on mutex