Protect the sync database by a mutex since it is used by the thread