One Row Lied to the Whole Team
A story about exactly-once, one restart, and the question nobody dared to ask.
Friday, 23:17.
Mei posted three words in the team channel: "Verified. Ship it."
Five minutes earlier, the order pipeline had come back from a restart. In the target table, order 8821 was a single row: PAID, 1299.00. Identical to MySQL. Primary key matched. Value matched. Even the decimals matched.
Ravi replied: "How many rows did you check?"
"All of them," Mei said. "Twenty-three thousand. Not one missing."
So the deployment log gained a line:
End-to-end exactly-once — verified.
It was the last release window before the quarter closed. The pipeline had already slipped twice. Our PM in Singapore had asked three times whether we could ship that day. Everyone exhaled.
Ravi said nothing. Later, I found what he had written in his notebook:
"All we proved was that it looked right."
Six weeks later, that distinction cost us a compliance finding.
1. What did that row actually prove?
Let me be clear: Mei did nothing wrong.
Her checklist had seven items — row count, primary key, amount, status, timestamp, encoding, null handling. She checked every one against the source. Twenty-three thousand rows, not one missing. That is a clean, professional verification.
The problem is that all seven questions were the same question:
"At the moment of the query, what value does this key hold?"
But exactly-once promises something else entirely:
"Across the entire lifetime of this pipeline, every source event is processed exactly once — including under every failure mode."
Those are different things.
One row can only tell you about state. It cannot tell you about process:
- When the task restarted, was the payment event for 8821 replayed?
- Did the audit trigger fire once, or twice?
- During the downtime, were any orders written and lost?
- If the source deleted an order, would the target resurrect it?
Mei answered the question she was asked. We let her answer sign off on a different one.
One row fooled the entire team — because it looked exactly like the right answer.
I eventually gave this failure mode a name: the Tyranny of the Final State.
When the final state looks correct, it quietly steps into every guarantee you never verified, and pretends to be them.
The final state is the easiest thing in the system to produce. Upsert absorbs duplicates. Buffers collapse intermediate updates. Idempotent design hides replays. And by the time you query, the system may already have self-healed. You are looking at the world after the repair, not the world at the moment of failure.
2. Six weeks later: the second audit row
The story should have ended there.
Six weeks later, during 11.11 peak season, our compliance team in Jakarta pulled the audit trail for a disputed payment. The email subject was short: Duplicate audit record for order 8821 — please explain.
The body had two lines:
Order 8821 shows two audit entries for a single payment event, 0.8 seconds apart. A payment cannot generate two entries. Please explain.
I read it three times.
Order 8821. The exact row Mei had personally checked.
Target table orders: one row, PAID. Fine.
Audit table orders_audit — maintained by our own trigger, appended on every write, and not on Mei's seven-item checklist:
SELECT id, order_id, status, created_at
FROM public.orders_audit
WHERE order_id = 8821;
-- 3312 | 8821 | PAID | 2026-03-14 23:09:45.812
-- 3313 | 8821 | PAID | 2026-03-14 23:09:46.634
Two rows. 0.822 seconds apart.
MySQL binlog: only one UPDATE for 8821 that evening.
CDC logs: the event E8821 appeared twice.
The room went quiet. I heard Mei breathe in. Ravi slid his notebook across the table — to the line he had written six weeks earlier.
"I checked," Mei said, her voice dry. "It was genuinely one row."
"It genuinely was one row," I said. "That's the problem."
3. Reconstructing the replay
We aligned four timelines — CDC logs, the engine's checkpoint record, PostgreSQL's audit table, and the MySQL binlog — and reconstructed the whole evening:
23:05:31 checkpoint 2847 completed
offset P0 = mysql-bin.000042:8871
23:07:12 job restored from checkpoint 2847, same job ID
23:09:44 CDC reads E8821 (8821: NEW → PAID)
23:09:45 sink commits E8821 to PostgreSQL (autocommit)
23:09:45 audit trigger writes entry 3312
23:10:02 worker process killed by OOM killer ← memory spike
23:10:31 alert fires, Mei restarts the job manually
23:12:18 job restores from checkpoint 2847, offset still P0
23:12:41 CDC reads E8821 again
23:12:42 sink commits E8821 again
23:12:42 audit trigger writes entry 3313
23:13:00 upsert overwrites by primary key — target still one row, PAID
23:17:02 Mei queries, sees one row, signs off
From the first commit at 23:09:45 to the replay at 23:12:42 — less than three minutes.
But the fatal window opened earlier. Checkpoint 2847 had completed. Checkpoint 2848 had not yet landed. The interval was 5 seconds, but barriers need to align, state needs to serialize, and the snapshot needs to reach shared storage. The process died just before 2848 committed.
So the restore point was still 2847, and the offset was still P0. Everything after P0 — including E8821 — was read again.
Here is the non-technical version:
You delivered the parcel to the customer, then filed the delivery slip. Before you filed it, you got hit by a car. When you woke up, you checked the records, saw no delivery, and delivered it again.
The customer received two parcels. But as long as you only ask "does the customer have the parcel?", you will never find out.
The crash isn't inside the SQL statement. It's between two commits.
A checkpoint isn't magic. It's a bookmark that says "restart here." And between the bookmark and the page, there is a stretch of road nobody owns. That stretch is the entire problem of exactly-once.
Turning on checkpointing does not turn a database's ordinary autocommit into a distributed transaction. To make a replay genuinely harmless, three things must still line up after a failure: the source offset, the pending transaction, and the final commit decision.
This is not a SeaTunnel problem. Debezium with Kafka Connect, Airbyte, and homegrown CDC all have the same window. The product name changes; the window doesn't.
4. The argument we should have had
Ravi had objected six weeks earlier.
"In this pipeline we need XA," he said. "Otherwise we're gambling."
Mei pushed back: "The target has a primary key and we use upsert. Writing twice still leaves one row. XA means tuning max_prepared_transactions, watching pg_prepared_xacts, and re-validating across a failover. That's overkill."
Ravi said one line nobody took seriously:
"You're not preventing duplicates. You're making them invisible."
He wasn't ignoring the cost. Every problem he raised was real:
- In XA mode you set
is_exactly_once = trueand use an XA-aware datasource. In other stacks the equivalent knob lives in the sink connector. -
max_retriesmust stay at 0 — that disables DML retries on failed batches, not every retry. A separatemax_commit_attemptsbudget still applies within a single commit or recovery call. - Prepared transactions hold locks and block VACUUM until resolved.
- On recovery the coordinator rescans prepared XIDs in batches. "Not found in the catalog" is not independent proof of commit — a manual rollback or a wrong target connection produces the same absence.
- A single batch is committed XID by XID. Between two XIDs there is a moment where a reader sees only the first one.
- After a primary/standby switchover, you must re-verify PREPARE and COMMIT on the new primary.
All of that is real operational cost. Ravi never claimed XA was free.
His argument reduced to one sentence: if you have promised that transactional side effects will not be duplicated by a replay, upsert cannot pay that bill.
For a small regional team, that cost matters twice. We did not have a dedicated DBA in every market, and our auditors in Jakarta were asking for evidence, not architecture diagrams. We chose "good enough." Six weeks later, compliance told us the line we drew was in the wrong place.
You can negotiate cost. You cannot guess the boundary. And boundaries get guessed when nobody in the room is willing to say the worst case out loud.
5. The three layers of the upsert lie
"Writing twice still leaves one row" is true — but only on the surface. It is three lies, stacked.
Lie one: writing twice leaves one row.
True — the target row is one row. But the audit trigger fired twice, and the compliance officer read two entries. Idempotence of a row is not idempotence of a system. You only hid the evidence somewhere outside the row.
Lie two: counter = counter + 1 is fine.
If the write is UPDATE orders SET version = version + 1 WHERE id = 8821, one replay adds one to version. If it is SET amount = amount + delta, the amount doubles. INSERT ... ON CONFLICT DO UPDATE guarantees an atomic statement, not that re-running the statement is harmless.
Lie three: an old snapshot overwriting is fine.
This is the nastiest one. If the replay brings an older image from an earlier checkpoint, it overwrites the new value with the old one: the order is SHIPPED, and the replay drags it back to PAID. That is state regression, and ordinary upsert has no mechanism to stop it.
There is a fourth, quieter layer: sink buffers collapse intermediate updates by key. An order going NEW → PAID → SHIPPED may be collapsed into a single SHIPPED write. The mode was never "one change equals one write" in the first place.
Upsert isn't exactly-once. It's a beauty filter for duplicate writes. It hides the evidence; it does not destroy it.
6. The Tyranny of the Final State
I wanted one idea from this incident that people could carry to work.
The Tyranny of the Final State: when a system's final state looks correct, it tends to replace every guarantee you never verified, and become the stand-in for "the system is correct."
It has three properties:
- It looks indisputable. You cannot argue with a correct row. It is right there, in black and white.
- It is cheap. Querying a row takes five seconds. Verifying a crash recovery takes half a day. People reach for the cheap one.
- It reinforces itself. Once "verified" is written into the deployment log, nobody wants to doubt it. Questioning costs more than accepting.
So the Tyranny of the Final State is not a technical problem. It is an incentive problem:
We were not fooled by the data. We were fooled by our own verification method — and that method was shaped by "we have to ship today."
Mei's seven items were not wrong. The checklist had only one dimension. She verified state; exactly-once promises process. State is a projection of process, and a correct projection does not mean the underlying process was correct.
If you remember one line from this article, make it this one:
Most teams' "exactly-once" translates to: I checked. Looks right.
7. Asking a harder question
Better verification does not mean more dashboards. It means deliberately breaking things.
We redid that verification in an isolated environment with fixed test keys and a sequence of events we could reconcile. Three drills:
Drill 1 — interrupt after the write is issued but before prepare.
Does the event replay after recovery, and can a target-side constraint stop it?
Drill 2 — interrupt after prepare but before the second-phase commit.
Do the in-doubt transactions in pg_prepared_xacts converge — recovered correctly by the coordinator, or left holding locks forever?
Drill 3 — target committed, acknowledgement lost, then recover.
Does the system mistake "committed" for "failed" and deliver again?
The third is the hardest to reproduce reliably. If you cannot do it, write "not verified" — do not pass a random kill -9 off as coverage.
Record five things per drill: checkpoint ID, source offset, expected XID, in-doubt transactions on the target, and a timestamp for each stage. After recovery, compare current values key by key, check expected deletes and audit probes, and confirm that in-doubt transactions converged.
You cannot prove your brakes work at an intersection with no traffic lights.
Mei added one item to the end of her checklist:
"If I killed the worker right now, what evidence would prove this row is still correct?"
If you cannot answer, you do not sign.
8. The bigger question: is exactly-once a myth?
Here is an opinion that may annoy some people.
Strict exactly-once is extremely expensive in a distributed system. It needs end-to-end transactional coordination — a transactional sink, an idempotent consumer, a replayable source. And even when all of that is in place, there are still external side effects: the payment callback, the email, the webhook. Those do not roll back with your database transaction. They need their own idempotency keys and reconciliation.
So my practical advice is: classify by the severity of the side effect, instead of chasing exactly-once everywhere.
| Level | Scenario | What you actually need |
|---|---|---|
| L0 | Pure analytics mirror, reconcilable and repairable | Final-state consistency + detectable gap alerts |
| L1 | Audit tables, event history | Event-level dedup + stable event identity + periodic reconciliation |
| L2 | Payments, notifications, external side effects | Transactional coordination + idempotency keys + a reconciliation protocol with the external system |
The lesson of order 8821: we verified it as L0 (final state), but it carried an L1 side effect (an audit trail). Misclassify the level, and the verification is wrong before it starts.
This matters more in our region than in most. Across Southeast Asia, data-protection regimes are tightening — Indonesia's PDP Law, Singapore's PDPA, Thailand's PDPA, Vietnam's newer personal-data rules. When an auditor asks for the trail of a single payment, "the table looks right" is not an answer. Duplicate audit entries are not a cosmetic defect; they are a finding with a remediation date attached.
Pursuing exactly-once is not wrong. What is wrong is pursuing it indiscriminately, then declaring victory with one row.
Epilogue: the row is still there
Order 8821 is still in the target table. PAID, 1299.00.
It looks exactly as it did that Friday at 23:17.
It never lied to anyone. We asked a question that was easy to answer, then treated the answer as a promise.
The line in the deployment log was rewritten. It now says:
"End-to-end exactly-once, verified at L1: three failure drills passed, audit-side reconciliation clean."
Every extra word in that sentence was bought by two audit entries.
So the next time someone tells you they have exactly-once, don't look at their architecture diagram. Don't look at their config. Don't look at their dashboard.
Ask one question:
"Have you ever killed the process?"


Top comments (0)