semaphore use in database.save