Does the outbox pattern prevent lost Kafka events? The database committed. The Kafka event never arrived.
A naive dual write lost its Kafka event after the database committed; the outbox delivered at the same crash point but duplicated an event when the relay died after Kafka acknowledged it.
Failure replay: lost versus duplicated events
Failure trace
Choose any step to jump to it.
Naive dual write: 3 steps. Ready to play.
At the tested crash point, yes: the naive dual write lost the Kafka event after PostgreSQL committed, while the outbox let a relay publish it after the kill. The trade-off showed up at a different crash point: killing the relay after Kafka acknowledged the send made the replacement publish the same event again.
What I did
I ran a plain Java request worker and a separate relay against PostgreSQL and Kafka in disposable containers. The outbox keeps a pending event in the same transaction as the business row; the relay publishes it and then marks it sent. I paused the worker just after the database commit in both the naive and outbox cases, then forcibly killed it before Kafka publication. An independent database connection and Kafka consumer checked what survived for each event ID.
What I saw
In the 50 standalone Windows trials, each case matched the plan ten times. At the matched post-commit crash point, the naive writer left a row with no event. The outbox left a row and an unsent entry, and the relay published one event after it started. Reversing the naive write order left a ghost event in Kafka with no committed row. Killing the outbox worker before commit left neither row nor event.
When I killed the relay after Kafka acknowledged its send, the target event appeared twice, but a second, untouched request still produced exactly one event. The two copies occupied different Kafka offsets: this was a second publish, not a second read of the same record.
What to do
- Compare the two designs at the same post-commit crash point, and check both stores by event ID.
- Kill the relay after Kafka acknowledges the send but before it marks the entry sent. Verify that pending work drains after restart.
- Check that downstream handling tolerates two records with the same event ID.
Limits
The standalone and reactor runs used a Windows host. A separate Ubuntu CI run passed all 50 trials, ten per case. The fixture used one Kafka broker and partition, one active relay, and one forced application crash per trial. It did not test broker or database failures, concurrent relays, or downstream deduplication.
10/10 means the specified outcome recurred every time at that deliberately chosen crash point. It does not estimate how often production crashes hit that point or establish a delivery guarantee.
Evidence
The results page includes the separate standalone and reactor reports, with database rows, outbox states, and Kafka offsets. The pre-registered plan gives the expected outcomes at each crash point.