Overlapping transaction reports can overwrite the newer charged total
Goal
Keep TransactionItem money totals consistent when two distinct provider reports overlap.
Steps to reproduce
- On a clean database, create an app-owned
TransactionItem. - Start
transactionEventReportforCHARGE_SUCCESS, 7.00, referencecharge-seven. - After it calculates
charged_valuebut before itsTransactionItem.save, report a secondCHARGE_SUCCESS, 11.00, referencecharge-eleven, and allow that report to finish. - Resume the first save. Both events now exist, but
charged_valuebecomes 7.00 instead of 18.00. Retrying either reference reportsalreadyProcessed: truewithout repairing the total.
This ordering is deterministic with Saleor's existing race_condition.RunBefore helper. The harness also exercised overlapping provider reports through real application connections in #36.
Expected behavior
Both accepted charge events must contribute to the durable charged total, 18.00. An older computation must not overwrite a newer projection.
Additional context
The mutation locks the transaction while saving each event, but releases the lock before recalculating and saving the transaction amounts. Both reports can therefore calculate from different event sets and save in reverse order. This differs from #19852, where a crash between event commit and projection leaves the total unfinished. The earlier Saleor #19836 demonstrates generated harness tests; the regression here can be pinned in Saleor's native suite without the harness dependency.
Environment
Current Saleor main (c69c56c), PostgreSQL-backed pytest run. No production incident is claimed.
Source: saleor/saleor