Duplicate invoice numbers are not allowed and will cause an error message to pop up ("The invoice number is already in use").
If a company creates an invoice with a number that has already been used, they get an error, and to proceed they must change the invoice number. However, it is possible to have documents that have the same number if they are not sent (drafts).
If you sent an invoice and later realized that you made a mistake, you can create a credit note against it, as shown here.