Collection (not record) locking

What is the solution for the invoice number duplication you mentioned?