I work on backend systems for banks in Brazil. This article starts with a real incident from my time at a Brazilian bank, where I worked on credit pipelines and direct debit processing. It then shows the same problem in a small .NET 8 webhook endpoint you can run yourself.
The incident
We received a CNAB file, the bank file format used in Brazil. While we were processing it, a timeout happened. The processing ran twice. We had two records for the same debits, and nothing in the code treated them as duplicates.
We noticed the problem when a duplicate debit arrived almost at the edge of the customer's account. The debit was already being sent to the customer. We had an event flagged by Dynatrace, a network service interruption. We went hunting for problems in the system in general, and that is when we caught some duplicate debits.
There was no financial loss.…