Can a 'no duplicates' check pass while the stored decision is wrong? One row. Wrong decision.
Every tested case left one row, but only an epoch-checked write preserved the newer decision in both write orders.
Yes. The stale decision could survive even though every tested case left exactly one row.
Question
If two deliveries produce different decisions, does storing exactly one row tell you which decision survived?
What I did
I forced the timing so that a slow worker lost its share-group lock and finished after the record went to a second worker, which decided differently. I compared the stored decision in both write orders.
What I saw
Every tested case ended with one row. A write that inserts or overwrites the row (a last-write-wins upsert) kept the stale decision when the stale worker wrote last. Insert-if-absent kept the stale decision when that worker wrote first. Only the epoch-checked write, which checks that the worker still holds the latest database claim, preserved the second delivery's decision in both orders. The stale worker's acknowledgement, sent after the other worker's, returned no error.
What to do
- Check the decision stored in the row, not just the row count.
- Test both write orders.
- Use the database claim to block stale writes; don't rely on the acknowledgement to do it.
Limits
Tested with Kafka 4.2.1, PostgreSQL 17, a plain Kafka client, a scripted model, and forced timing.
Evidence
The results compare the stored decision across both write orders; the DEV article explains why a clean row count wasn't enough.