Article
Handling Concurrent Redemption Operations in .NET and MySQL
A practical design note for preventing double state transitions when Reject and Cancel requests race each other.
Problem
Two requests can reach the same business entity at almost the same time. Each request looks valid when it starts, but only one transition should win.
The bug usually appears when validation and mutation are separated by enough latency for a second request to read the old state.
Design
The simplest reliable shape is:
- Read the current state inside a transaction.
- Lock or conditionally update the row.
- Re-check the transition rule inside the protected boundary.
- Write the result and an idempotency record.
My rule of thumb
If the workflow has financial, inventory, or irreversible side effects, the correctness boundary belongs in the database transaction, not only in application-level validation.