added mutex, MySQL connection check