# An order service handler writes an order to Postgres and publishes order_placed to Kafka in the same

Canonical URL: <https://datadriven.io/problems/an-order-service-handler-writes-an-order-to-postgres-and-pub-90cebff1>

Domain: Pipeline Design · Difficulty: medium

## Problem

An order service handler writes an order to Postgres and publishes order_placed to Kafka in the same function. There is no transaction across the two systems. Four outcomes are possible: both succeed, DB-only (silent ghost orders), Kafka-only (phantom events), or both fail (acceptable retry). Two of the four break invariants. A nightly recon job catches drift but enough leaks that notifications fire for orders that never shipped. Distributed transactions (XA, 2PC) do not solve this in modern infra. Spot the dual write by adding four marker nodes off the handler, one per outcome, each named with the invariant that breaks (or that the path is acceptable).

## Related

- [All practice problems](https://datadriven.io/problems)
- [Mock interview mode](https://datadriven.io/interview/an-order-service-handler-writes-an-order-to-postgres-and-pub-90cebff1)
- [System Design Interview Questions](https://datadriven.io/data-engineering-system-design)
- [Data Engineering Interview Prep Guide](https://datadriven.io/data-engineer-interview-prep)
- [Daily Challenge](https://datadriven.io/daily)

---

Source: DataDriven (https://datadriven.io). 100% free data engineering interview prep. Live code execution against Postgres 16, Python 3.11, and Spark sandboxes. No paywall, no premium tier, no signup gate.