Data and Knowledge SystemsIngestion and freshnessPrincipal
Why does an atomic source transaction not guarantee an atomic multi-table reporting view?
By Amit Kumar4 min readWorked answer includedReviewed 28 Sept 2026
The question
Interview question
A database commits an invoice adjustment and matching ledger entry in one transaction. Change-data-capture events reach separate table topics, and the reporting view exposes the invoice change before the ledger change. The assistant flags a mismatch that never existed in the source. Explain the consistency boundary, design a read or publication barrier, and state what transaction metadata can and cannot establish across separate downstream systems.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
Change data capture, or CDC, exports source mutations so another system can update a derived view. A materialized view is stored derived data rather than a live query over the source transaction. Once separate workers publish parts of that view, its visibility rules must be designed explicitly.
The source transaction was atomic in the source. The downstream projection is a different system, with different topics, consumers, offsets and visibility rules. Individual event delivery does not make a multi-table materialized view transactionally visible to readers. Debezium's PostgreSQL connector documentation describes transaction metadata, including ordering information, when enabled. That can help a consumer identify boundaries, but it does not automatically commit multiple target indexes as one snapshot.
I would compare source transaction ID and commit position, the two row-change events, topic partitions, consumer offsets and target projection versions. Check whether both events were emitted and merely processed at different times, or whether one was dropped. If they are present, the report needs an explicit consistency contract. It can wait until every required projection has applied at least the source commit position, read a source snapshot, or publish a versioned report only after the transaction's relevant changes have been staged together. A watermark per table is useful only if it represents compatible source positions and the reader knows what a consistent cut means. Taking the numerical minimum of unrelated offsets is not enough.
Consider a hypothetical invoice total changing from 100 to 80 together with a 20 credit entry. If a report sees 80 and the old zero-credit ledger, it can infer a false imbalance. A barrier can collect the transaction’s expected changes, apply them in one target transaction, and expose a new projection revision only after commit. If the targets cannot share a transaction, publish a manifest naming completed immutable versions and make the reader pin it. Counting expected events is useful only when the connector’s metadata and source scope actually cover the participating records.
For a highly used reporting path, I would build a projection that applies the related changes under one target transaction or exposes a committed report version. For an exploratory AI question, the assistant can check the projection lag and decline to assert a cross-table inconsistency while sources are at different positions. The answer should state the source cutoff it used. If the source spans separate databases with no single commit, a transaction ID cannot magically create atomicity across them. Then the business definition must tolerate or reconcile partial state.
The interviewer may ask whether simply waiting five seconds solves it. It reduces ordinary lag and gives no guarantee during a stalled consumer. A bulk snapshot races the change stream concerns the initial snapshot meeting a change stream. The index event arrived, but the document transaction rolled back. What should search believe? concerns an event published before its database transaction commits. Here the database committed correctly and the CDC stream is complete, yet readers observed a partially applied cross-table transaction downstream.
A completion marker is safe only if it cannot overtake unfinished work. If one table worker has applied transaction T and another has not, the coordinator must leave T unpublished even when it has seen a later transaction on the first table. Keep a record of outstanding participating events or use a target transaction that cannot become visible until its writes commit. A reader must also pin the publication version for the whole report. Otherwise one query can read the old invoice revision and a second query the new ledger revision despite both revisions being individually valid.
This has a cost. Buffering a large source transaction uses memory or durable staging space, and waiting for its slowest table increases report latency. Set limits and spill safely rather than silently publishing a partial transaction when a buffer fills. Test a consumer crash after one table write, a duplicated event and an END marker arriving before a worker finishes. The repaired view must contain the complete transaction once, and a timeout should produce a bounded unavailable or explicitly partial result rather than an invented mismatch.
Related questions
Keep practising data and knowledge systems
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux