Advanced
Open
Pro
Exactly-Once Payment Capture Under Redelivery
A consumer reads CapturePayment{order_id, amount} messages from a
Kafka topic and calls a third-party payment gateway. During an incident
you find that 40 customers were charged twice. Logs show the consumer
committed offsets after each batch of 100 messages, and one pod was
OOM-killed mid-batch.
- Explain step by step how the double charge happened.
- A colleague proposes "turn on Kafka exactly-once semantics
(
enable.idempotence=trueand transactions)". Will that fix it? Why or why not? - Design a fix that guarantees each order is charged at most once even if the message is delivered five times. State exactly where the deduplication state lives and what happens on a crash between the gateway call and the database write.
Share this question