We recreated the replication slot. Debezium said RUNNING, and five rows never arrived.

With only a snapshot offset stored, a Debezium 3.7.1 connector resumed as RUNNING after its slot was recreated; five rows written meanwhile never reached Kafka.

Published
Reading time
14 min read
One Debezium connector across a recreated slot: the stored offset is at row 5, from the initial snapshot; rows 11 to 15 are written while the slot is gone; the slot is created again before rows 16 to 20; the connector resumes at row 16 and reports RUNNING, and rows 11 to 15 are missing from the topic One Debezium connector across a recreated slot: the stored offset is at row 5, from the initial snapshot; rows 11 to 15 are written while the slot is gone; the slot is created again before rows 16 to 20; the connector resumes at row 16 and reports RUNNING, and rows 11 to 15 are missing from the topic
The offset said row 5. The new slot began after row 15. The connector resumed and reported RUNNING.
On this page

We stopped a Debezium connector on PostgreSQL, dropped its A replication slot records the WAL position that a standby or logical consumer has confirmed, and PostgreSQL retains all WAL after that position. An abandoned or stalled slot therefore grows pg_wal until the disk fills, unless max_slot_wal_keep_size limits it., created the slot again under the same name, and resumed the connector. It went back to RUNNING. The five rows written while the slot was gone never reached Kafka, and no error was reported anywhere.

It happened to one kind of connector: one whose only stored offset came from its initial snapshot, which is what a new pipeline on a quiet table has. A connector that had already streamed changes failed instead, and loudly. The quiet one is the one that loses data.

Operating rule. After anything touches a replication slot (a failover, an upgrade, a manual drop), compare the connector’s stored offset with the slot before the connector resumes. Alert on the connector’s state and on slot lag, and read RUNNING as “the task is alive”, not “the topic is complete”.

The test

Debezium 3.7.1.Final on Kafka Connect, with one Kafka 4.0.0 broker in KRaft mode and PostgreSQL, each in a container on a private Docker network. The Kafka Connect scenarios ran on PostgreSQL 13, 17 and 19, and all of them passed on 2026-12-01. The connector reads one table, customers (id, email), with the pgoutput plugin and a publication filtered to that table. snapshot.mode is left at its default, initial. The table starts with rows 1 to 5.

  1. Register the connector. It snapshots rows 1 to 5 and commits an offset. Stop it, and wait until nothing is reading the slot.
  2. Insert rows 11 to 15. These are the rows the connector will be missing.
  3. Drop the slot and create it again with the same name.
  4. Insert rows 16 to 20.
  5. Resume the connector, then read its state and the topic.

The second case is the same with one change. Before the stop, rows 6 to 10 are inserted and the connector is left to stream them, until its offset stops moving. Its stored offset was then written while streaming, not by the snapshot. The first case skips rows 6 to 10 so that the rows of the gap are 11 to 15 in both.

Where the connector resumes, and where the new slot starts

customersPostgreSQL table
Replication slotpgoutput, same name
Connectorstored offset
Kafka topicrows asserted

Snapshot only: the only stored offset came from the initial snapshot

A new pipeline on a quiet table

  1. Register the connector. It snapshots rows 1 to 5 and commits an offset. Stop it, and wait until nothing is reading the slot. Stored offset written by: the initial snapshot. In the topic: 1 to 5.
  2. Insert rows 11 to 15. These are the rows the connector will be missing.
  3. Drop the slot and create it again with the same name. A new slot starts at its own position, not at the connector's.
  4. Insert rows 16 to 20.
  5. Resume the connector. Its offset is before the gap and the slot's position is after it, so everything between the two is never sent. The connector reported RUNNING, the state a healthy connector reports. In the topic: 1 to 5, 16, 20. Not in the topic: 11 to 15. Error: none.

Streamed first: the stored offset was written while streaming rows 6 to 10

Rows 6 to 10 streamed before the stop, until the offset stopped moving

  1. Register the connector. It snapshots rows 1 to 5. Before the stop, rows 6 to 10 are inserted and the connector is left to stream them, until its offset stops moving. Stored offset written by: streaming, rows 6 to 10. In the topic: 1 to 5, 6, 10.
  2. Insert rows 11 to 15, drop the slot and create it again with the same name, then insert rows 16 to 20.
  3. The task went to FAILED on resume, and this time the connector said so. A failed task is something an alert on connector state can see. Not in the topic: 11 to 15, 16, 20. Error: trace contains "trying to read change stream starting at".
Debezium 3.7.1.Final, one table, snapshot.mode at its default, initial; the rows the harness asserts.

What the connector did

Case Stored offset written by After the resume In the topic Not in the topic Error
Snapshot only the initial snapshot RUNNING 1 to 5, 16, 20 11 to 15 none
Streamed first streaming, rows 6 to 10 FAILED 1 to 5, 6, 10 11 to 15, 16, 20 trace contains “trying to read change stream starting at”

The table lists the row ids the harness asserts: it looks for each id named in the “In the topic” column and fails the scenario if one is missing or if one of the “Not in the topic” ids is there.

Snapshot only. The harness waited for RUNNING, waited another 15 seconds, and read the topic. Rows 1 to 5 were there, and so were rows 16 and 20, written after the new slot was created. Rows 11 to 15 were not. The connector reported RUNNING, the state a healthy connector reports.

Streamed first. The task went to FAILED on resume. Its trace contains trying to read change stream starting at; in the tool’s documentation the full message reads “The connector is trying to read change stream starting at … but this is no longer available on the server”. None of the rows checked after the gap, 11 to 15, 16 and 20, reached the topic, and this time the connector said so. A failed task is something an alert on connector state can see.

The tail of that message, “no longer available on the server”, also appeared in a third scenario, where the slot was dropped and not created again and the connector had streamed first: the task failed at its next start. We did not measure a snapshot-only connector whose slot is simply gone.

How the comparison catches it

A connector resumes from the offset Kafka Connect has stored for it. A logical slot starts sending from the position it has confirmed. When the slot was created again, its position is after the gap and the connector’s offset is before it, so everything between the two is never sent.

pg-cdc-doctor’s check for this, CDC082, reads the connector’s committed offsets from the Kafka Connect REST API (GET /connectors/<name>/offsets, served from Kafka 3.6) and the slot’s confirmed_flush_lsn from pg_replication_slots. If the slot is ahead of the offset, or the slot is gone while the connector has an offset, it is a fail. Two settings turn that into an info: snapshot.mode = always when the slot is gone, because the connector reads every table again at start, and lsn.flush.mode = connector_and_driver when the slot is ahead, because the driver also confirms keep-alive positions that cover WAL of no captured table, so a slot ahead of the offset is not proof of a gap.

Why a slot gets created again

A failover before PostgreSQL 17. The measurement behind pg-cdc-doctor’s CDC050: for each version, a primary with a streaming standby, both in Docker; a logical slot created on the primary; the standby promoted; then the question of what the promoted server has.

PostgreSQL Slot on the promoted server
13.23 absent: replication slot "measure_cdc050" does not exist
14.24 absent
15.19 absent
16.15 absent
17.12, created as a failover slot present, once synchronized to the standby, and decoding from it worked

Before 17 the slot is not on the promoted server, so it has to be created again, and a new slot starts at its own position, not at the connector’s. Reports of the same failure are public: one on Patroni dropping slots it does not know about, one on slots gone after a Patroni failover, and one on the event-gap risk after a promotion. We measured a Patroni failover itself, with a killed primary and a promotion, in an earlier post; that one is about the physical side and does not cover logical slots. The measurement above is plain PostgreSQL promotion, not Patroni.

A managed failover or a major-version upgrade. The operations runbook of our data-platform-architecture names an RDS failover and a major-version upgrade as the causes of a lost slot. That is what it plans for; we did not measure either on RDS.

A manual fix. The same runbook says that when a stalled slot’s retained WAL nears the threshold and the connector cannot catch up, the slot is dropped, because the product comes first. That is a reasonable decision, and it is the moment the gap is made. pg-cdc-doctor’s fix text lists three causes to look for: a manual pg_drop_replication_slot, a failover to a standby without the slot, and slot.drop.on.stop = true. Whichever it was, a dropped slot means a re-snapshot before the pipeline resumes.

What getting back costs

The re-snapshot is the way back, and we rehearsed it at the lab’s size. The lab copy of a SaaS company’s database on PostgreSQL 17 held 31.2 million rows. The slot was dropped and created again, with a 3-minute gap of writes in between.

  • Time. 100 seconds from the new slot to a green reconciliation, 51 of them the snapshot.
  • Current state. No row’s current state was lost. All 2,160 events written in the gap arrived in staging.
  • History. None of the 20 intermediate versions made in the gap appeared. 10 accounts and 10 users had each been changed twice in the gap, and the copy holds only the last state of each. The 30 user deletes in the gap were dated at the snapshot, 150.5 seconds after their real commit.
  • 100 sfrom the new slot to a green reconciliation, 51 of them the snapshot
  • 2,160 eventswritten in the gap, all arrived in staging; no row's current state was lost
  • None of 20intermediate versions made in the gap appeared

One rehearsal of the lab's own capture process, not Debezium, on a 31.2-million-row lab copy on PostgreSQL 17, with a 3-minute gap of writes; the 30 user deletes in the gap were dated at the snapshot, 150.5 seconds after their real commit.

A re-snapshot restores state, not history. Anything that reads the history of a record, an audit of changes or a slowly changing dimension, has a hole in that window. The runbook says to record the gap’s start and end in an audit table, so that a report over that window can say so. The start is the commit time of the last change captured before the slot went. The end is the time the new snapshot was taken.

This is the lab’s own capture process, a stand-in for a managed CDC service, not Debezium and not a managed service’s full load, and the time grows with the size of the tables. That process also refuses to start when its slot is gone, and says why: the slot is gone: start with --resnapshot to recreate it and copy again. The silent case above is the one where a slot exists again and nothing says it is the wrong one.

Checks before a connector resumes

  • Compare the stored offset with the slot. Read the connector’s offsets (Kafka 3.6 or later) and the slot’s confirmed_flush_lsn. If the slot is ahead, do not restart the connector as it is. Re-snapshot the captured tables, either with an incremental snapshot signal or with snapshot.mode = always for one start, and find out what moved the slot.
  • On PostgreSQL 17 and later, use failover slots and check they are synchronized. The standby’s pg_replication_slots shows synced = true once it holds the slot. Before 17, plan for the slot being absent after a promotion, as it was on 13 to 16.
  • Alert on more than RUNNING. Alert on the state of the connector and of each task. Alert on slot lag and retained WAL, too. A failing heartbeat.action.query left the task RUNNING, with the error only in the worker log (CDC067). With lsn.flush.mode=manual the slot’s confirmed_flush_lsn did not move and the server retained WAL without bound (CDC066); slot lag and retained WAL show that.
  • Plan the re-snapshot before you need it. Time it at your table sizes. Know what history it cannot restore, and decide where the gap’s start and end will be recorded.

pg-cdc-doctor reports this as CDC082. It reads the offset through the Kafka Connect REST API and the slot from the database, and changes nothing on either side, so it can run before a resume. The two cases above are scenarios in its test suite: pg-cdc-doctor.

Boundary. One connector per case, one table of at most 20 rows, snapshot.mode at initial, one run per case on each of PostgreSQL 13, 17 and 19. The silent case needs a slot of the same name to exist again before the connector starts; we created it by hand with SQL. Slot recreation by a failover on RDS, by Patroni or by an upgrade was not tested. The promotion measurement is plain PostgreSQL in containers, one run per version, and its slot was inactive at the time. The re-snapshot figures come from one rehearsal of the lab’s capture process, not from Debezium.

Frequently asked questions

Does RUNNING mean a Debezium connector has delivered every row?

No. In a test on Debezium 3.7.1.Final, a connector whose only stored offset came from its initial snapshot resumed as RUNNING after its PostgreSQL slot was dropped and created again. Rows 11 to 15, written while the slot was gone, never reached the topic, and no error was reported. RUNNING says the task is alive, not that the topic is complete.

What does a Debezium PostgreSQL connector do when its replication slot is dropped and created again?

It depends on how its stored offset was written. If the offset was written while streaming, the task fails on resume with “trying to read change stream starting at … no longer available on the server”, and nothing after the gap reaches the topic. If the only offset came from the initial snapshot, the connector resumes as RUNNING and the rows written in between are lost without an error. A new slot starts at the position it confirmed, and the connector resumes from its own offset.

Why is the logical replication slot missing after a PostgreSQL failover?

Before PostgreSQL 17 a logical slot is not carried to the standby. In a test with a streaming standby that was promoted, the promoted server had no logical slot on 13.23, 14.24, 15.19 and 16.15. On 17.12 a slot created as a failover slot was on the promoted server once it had been synchronized to the standby.

Does a re-snapshot restore everything after a lost slot?

It restores current state, not history. In a lab run on 31.2 million rows, the re-snapshot took 100 seconds from the new slot to a green reconciliation, and no row’s current state was lost. None of the 20 intermediate versions made in a 3-minute gap appeared, and the 30 user deletes in the gap were dated at the snapshot, not when they happened.

The scenarios and the measurement are in pg-cdc-doctor, with the re-snapshot rehearsal in data-platform-architecture. More on PostgreSQL and Kafka and streaming.

Terms in this piece
replication slot
A replication slot records the WAL position that a standby or logical consumer has confirmed, and PostgreSQL retains all WAL after that position. An abandoned or stalled slot therefore grows pg_wal until the disk fills, unless max_slot_wal_keep_size limits it.

Basant Bhattarai is a data and AI architect with 9+ years in industry. He leads a team of five engineers and the architecture of data and AI platforms end to end: the data model, the databases underneath, governance and SOC 2 controls, and the AI built into them. He writes up what he measures, with the method beside each figure.

Currently: Senior Data Engineer at UXCam.

Building something similar? I'm open to long-term consulting, contract or full-time roles. Work with me