use semaphore to lock sql