i have a reservation system in php ,and our QA team found a case that one free spot may be reserved by two different people if they clicked the reserve button at the same time . what i have tried is locking insertion on that table using semaphore but this slow the insertion for other users and may cause long semaphore wait system crash. any one can please share an idea or if he faced this problem before