Locking may be a good option but the performance to integrity tradeoff .....
Locking might also frustrate users when trying to insert
Anyway, I think i'll use a different way of getting the primary key other than relying on the last insert
Or maybe employ the use of a surrogate key
I'll research on the matter then share the best solution in my view