Quick revision
The short answer
Connector status and consumer lag cannot catch a silent stall, because a connector can report RUNNING while reading nothing, and lag is zero when nothing is produced. We write a heartbeat row in every source database every few seconds and measure end-to-end freshness at every sink as now minus the newest heartbeat seen, alerting against each pipeline's freshness SLO. Heartbeats also keep replication positions moving on quiet databases, and regular count and checksum reconciliation finds missing or duplicated changes, while failover tests catch the gaps that usually start there.
What to remember
In this answer, we saw that connector status and consumer lag describe components and stay green during a silent stall. Heartbeat rows written in each source and measured at each sink give end-to-end freshness against an SLO, and they also keep replication positions moving on quiet databases. Reconciliation with counts and checksums finds loss and duplicates that freshness cannot, and including CDC in failover tests and runbooks closes the gap where most stalls start.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Connector status and consumer lag cannot catch a silent stall, because a connector can report RUNNING while reading nothing, and lag is zero when nothing is produced. We write a heartbeat row in every source database every few seconds and measure end-to-end freshness at every sink as now minus the newest heartbeat seen, alerting against each pipeline's freshness SLO. Heartbeats also keep replication positions moving on quiet databases, and regular count and checksum reconciliation finds missing or duplicated changes, while failover tests catch the gaps that usually start there.
Why this question is asked
A pipeline that crashes is easy: something turns red and someone gets paged. The dangerous pipeline is the one that looks healthy and quietly stops moving data, as happened here for five hours after a database failover. Interviewers ask senior engineers this because it tests whether they monitor what users care about, fresh and complete data, rather than what the tools happen to expose. In this answer, we will see why the usual signals missed the stall, build freshness monitoring from heartbeats, use reconciliation to catch loss, and look at failover, where most of these gaps begin.
1Why Status and Lag Both Said Everything Was Fine
Kafka Connect reports a connector as RUNNING when its task is alive. After the failover, the connector was alive but connected in a way that produced nothing: for example, it reconnected to the new primary where its replication slot did not exist yet, or kept waiting on a stream that would never deliver. Nothing threw an exception, so the status stayed green.
Consumer lag measures how far a consumer is behind the end of a topic. If the connector writes nothing, the end of the topic does not move, the consumers have read everything there is, and lag is zero. So the most reassuring number on the dashboard was reassuring precisely because the pipeline was broken. Both signals describe components; neither describes whether data is flowing from source to sink.
2Measuring Freshness With Heartbeat Rows
The fix is to send a known change through the whole pipeline on a schedule and watch for it at the end. We create a small heartbeat table in each source database and update it every few seconds. That update travels through the log, the connector, Kafka and the consumer like any other change. Each sink records the newest heartbeat it has seen, and freshness is simply now minus that timestamp.
5 messages in order. Play them, or step through them one at a time.
Freshness is measured where the data is used, so it catches a stall anywhere along the path.
Notice that this measures exactly what customers feel. If any part breaks, the database, the slot, the connector, Kafka, the consumer or the sink, freshness climbs steadily, even if every component claims to be healthy. We alert when it exceeds the pipeline's freshness SLO, for example two minutes for prices and thirty minutes for the warehouse, so a stall like this one pages within minutes instead of being found by customers after five hours.
3Heartbeats Also Protect the Source
There is a second reason for heartbeats. On a quiet database, the tables we capture may not change for hours, so the connector has nothing to confirm, and the replication slot in PostgreSQL does not advance. If other databases on the same server are busy, the shared WAL keeps growing and the slot holds all of it, which can fill the disk. In MySQL the equivalent risk is the connector's stored binlog position aging past the binlog retention. A heartbeat change on a captured table gives the connector something to acknowledge every few seconds, so positions keep moving. We also watch retained WAL per slot directly.
4Reconciliation Catches What Freshness Cannot
Freshness tells us data is flowing. It does not tell us the data is complete. A connector can skip a range of changes after a failover and then carry on, and heartbeats will look perfect. So we also reconcile on a schedule: compare row counts and checksums per table, or per day of data, between source and each sink. A checksum can be as simple as a sum of hashes of the key and version columns, computed the same way on both sides.
We run it for recent closed periods, for example yesterday's rows every hour, so in-flight changes do not cause false alarms, and we alert on any difference beyond a small tolerance. When a bucket differs, we drill down by hour and then by key range to find the missing rows and re-snapshot just those. This finds lost and duplicated changes even while data keeps flowing.
5Failover Is Where Silent Gaps Begin
Most silent gaps start at a database failover. In PostgreSQL, logical replication slots historically lived only on the primary, so after a failover the new primary had no slot and changes made in between were lost to CDC; PostgreSQL 17 added slot synchronisation to standbys for failover, which must be configured explicitly (check your version and managed service). In MySQL, GTIDs let a connector resume on the new primary, but only if the binlogs it needs still exist there.
So we test failover with the CDC pipelines attached, in a staging environment and in planned game days, and check freshness and reconciliation afterwards. The database runbook gets a CDC section: verify slots or positions on the new primary, restart connectors if needed, and trigger a re-snapshot when a gap is suspected.
- Freshness SLO alertnow minus newest heartbeat at each sink; pages on-call
- Reconciliationcounts and checksums per table per period; finds loss and duplicates
- Source protectionretained WAL per slot, binlog position age
- Component healthconnector status, task errors, consumer lag; useful for diagnosis
- Failover drillsCDC included in database runbooks and game days
5 layers, from the top down. Step through them one at a time.
Component signals help us find the cause; freshness and reconciliation tell us there is a problem.
6Follow-up questions
Who should own the freshness SLO: the database team, the platform team or the consumers?
The consumers set the target, because only they know how stale prices or search results may be before it hurts the business. The platform team that runs the CDC pipelines owns the measurement, the alerts and the on-call response, since it can act on every component between source and sink. The database team owns the source-side duties, such as slots, retention and failover runbooks, and agrees to them as part of the same SLO. Writing those three roles down is what stops a stall from being everybody's and nobody's problem.
How do we avoid false alarms when a database is legitimately quiet?
That is exactly what heartbeats solve. Because the heartbeat changes every few seconds regardless of business traffic, a quiet database still shows fresh data, and rising freshness always means the pipeline is stuck rather than that nobody is buying anything.
What freshness threshold should we alert on?
Several times the normal end-to-end delay and comfortably below the business tolerance. If the pipeline normally delivers in 5 seconds and prices may be 5 minutes stale, alerting at about 2 minutes leaves time to act before customers notice.
7Conclusion
In this answer, we saw that connector status and consumer lag describe components and stay green during a silent stall. Heartbeat rows written in each source and measured at each sink give end-to-end freshness against an SLO, and they also keep replication positions moving on quiet databases. Reconciliation with counts and checksums finds loss and duplicates that freshness cannot, and including CDC in failover tests and runbooks closes the gap where most stalls start.
Open with
The lesson from that incident is that connector status and consumer lag do not measure what we care about. A connector can be RUNNING and read nothing, and when nothing is produced, lag is zero.
Then, if they want more
So I would monitor end-to-end freshness. Each source database gets a heartbeat table that is updated every few seconds, either by Debezium's heartbeat query or a small job. That change flows through the whole pipeline, and each sink records the newest heartbeat it applied, so freshness is now minus that timestamp.
We alert when it passes the pipeline's SLO, say two minutes for prices, which would have caught the five-hour stall within minutes. Heartbeats have a second benefit: on quiet databases they keep the replication slot or binlog position moving, so WAL does not pile up, and I would also alert on retained WAL per slot.
Freshness does not prove completeness, so I add reconciliation: counts and checksums per table per day between the source and each sink, run regularly on closed periods. Finally, failover is where most silent gaps start, so I would test failover with CDC attached and put slot and position checks into the database runbook.
About this answer
- Last updated
- 13 November 2026
- Versions it names
- PostgreSQL 17
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "How do you monitor CDC pipelines so that silent stalls and data loss are detected within...": https://scrivio-interview-library.netlify.app/architecture/storage-and-pipelines/931200a473/