Wrong Contribution ID passed to TokenValueEvent and Duplicate Invoice Numbers for Contributions created around same time
New description after diagnosis: Code was setting invoice number to a predicted next ContributionID instead of waiting for the Contribution ID to be set.
Overview
When two contributions are made at the same time (same datetime to the second), one of the contributions is assigned a duplicate invoice_number. The invoice number is assigned based on a Contribution ID, therefore, we infer that the Contribution ID is corrected later in the request handling, but the invoice ID is not updated and is therefore a duplicate of another existing contribution.
There is no token for invoice number and we are not using the System Workflow messages that make it available as a variable in Smarty processing.
Our custom token sets it from the Contribution ID passed to TokenValueEvent. Perhaps this is a better framing of the bug over-all... the incorrect Contribution ID is passed to the TokenValueEvent. This is probably inconsequential for most cases since Contribution ID is not a likely token or token dependency.
Reproduction steps
It has been observed multiple times in our high-volume event registrations. Reproduction would require submitting simultaneous requests. This might involve some luck, but maybe an appropriately high load compared to the system configuration would trigger the condition reliably.
We are using the payflowpro payment processor extension.
Current behaviour
Two contributions, with different but sequential Contribution ID's, share the same invoice_number and are both returned in a search by invoice number.
Expected behaviour
The invoice_number should be unique and is expected to be derived from Contribution ID and invoice prefix.