Yes. Kafka redelivered the same record after the database committed, but a unique key prevented a second row.

Question

What happens if the database commits before the Kafka consumer gets a chance to acknowledge the record?

What I did

I ran two real agent JVMs (Java virtual machines) and tested crashes inside the transaction and after the PostgreSQL row committed but before the consumer could acknowledge the record.

What I saw

After the commit, Kafka redelivered the same record to the replacement, which added no second row because of the unique key. A crash inside the transaction left no row; the replay then created one. The in-memory baseline repeated the side effect after restart. Under these failures the database held one row per customer message, not exactly-once execution.

What to do

  • Check separately whether the handler ran again and whether it added a second row.
  • Test a crash inside the transaction and one after commit but before acknowledgement; they leave different work for the replacement.

Limits

Tested with two JVMs, PostgreSQL, Kafka, a scripted model, and named crash points.

Evidence

The results document both crash points and the in-memory baseline. The DEV article walks through the replay after the commit.