Lock mysql table to prevent select and insert at the same time
With LOCK you probably mean locking entire table, that should not be needed in InnoDB. Check SELECT .. FOR UPDATE.

But duplicate values should be forbidden with the use of UNIQUE indexes, that way the worst thing you get is an "duplicate key" error and not a duplicated row. 

If you have proper indexes in place, you may even use INSERT .. ON DUPLICATE KEY UPDATE.