Features & Delivery Guarantees
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. |
A migration pipeline is only as trustworthy as the guarantees underneath it. When the new Bookshop database on PostgreSQL is filled from change events of the legacy Oracle schema, three questions decide whether the copy can be believed: does every committed change arrive, can a change arrive twice, and do changes arrive in the right order? This page answers those questions for Debezium. It covers the features that make log-based CDC complete (snapshots followed by streaming, deletes, old row images, transaction metadata), the at-least-once delivery that Debezium provides by default, how consumers turn at-least-once into an effectively-once result, the ordering Debezium preserves, and the exactly-once support available on Kafka Connect, including its known limits.
Checked on 2026-11-09 against Debezium 3.7.1.Final and Apache Kafka 4.3.1 (the version in the Debezium 3.7.1.Final
container images). A Kafka Connect worker with exactly.once.source.support=enabled was started with Docker on
2026-11-09, and an Oracle connector configuration with exactly.once.support=required and
provide.transaction.metadata=true passed the Connect configuration validation (apart from the database connection,
which was not available). The event examples and consumer code are derived from the official documentation and were not
run against a database.
What log-based CDC gives you
The official features page sums up what Debezium’s log-based capture provides compared with polling or dual writes:
-
All data changes are captured, because every committed change is in the log.
-
Change events are produced with a very low delay (milliseconds for MySQL or PostgreSQL) without the CPU cost of frequent polling.
-
No change to the data model is needed. A
LAST_UPDcolumn like the one on the legacyBOOKtable is not used, and it does not matter if the legacy application forgets to update it. -
Deletes are captured.
-
The old row state and extra metadata (transaction id, and on some databases the statement that caused the change) can be captured, depending on the database’s capabilities and configuration.
On top of that, every connector offers include and exclude filters for schemas, tables and columns, column masking for sensitive data, JMX monitoring, and the Debezium SMTs for routing, filtering and event flattening. Migration Strategies compares these properties with dual writes, batch ETL, triggers and query-based capture. The rest of this page looks at each guarantee in detail.
Snapshot followed by streaming, with no gap
The first time a connector starts, the log no longer holds the history that built the legacy tables. The connector therefore takes an initial snapshot and then switches to streaming. The handover is designed so that nothing falls between the two:
-
The connector records the current log position (for Oracle, the current SCN).
-
It reads the structure and then the rows of every captured table as of that position (Oracle uses flashback queries at the recorded SCN), and emits one
r(read) event per row. -
It starts streaming from the recorded position. Changes committed while the snapshot was running are in the log after that position, so they are streamed as normal
c,uanddevents.
A consumer therefore sees every row once from the snapshot and then every later change. If a row changed during the
snapshot, the consumer may see the snapshot value followed by the update, which is harmless when updates are applied
as upserts. The modes and their trade-offs (locks, undo retention, ORA-01555, incremental snapshots that run in
chunks while streaming continues) are covered in Initial Snapshots and
Incremental & Blocking Snapshots.
No lost changes, and what protects that promise
Once streaming, Debezium does not skip committed changes: it resumes from the stored offset after every restart. The promise rests on conditions that are outside Debezium’s control and must be part of the migration plan:
| Condition | Why it matters | Bookshop measure |
|---|---|---|
The log still contains the stored position |
If the connector is down longer than the legacy database keeps its archived logs, the position is gone and only a new snapshot can recover |
Agree an archive log retention on the Oracle side that is longer than the longest planned outage; alert on connector downtime |
Offsets and schema history are durable |
Lost offsets mean a re-snapshot; a lost schema history means the connector cannot interpret the log |
Kafka Connect in distributed mode, schema history topic with infinite retention and replication factor 3 |
Kafka does not lose acknowledged records |
Records acknowledged by one broker and then lost in a failover are gone, although the offset has already moved on |
Replication factor 3, |
Filters are correct |
A table that is not in |
Review the include list against the legacy schema; reconcile row counts (see Verification & Reconciliation) |
Deletes and tombstones
A delete in the legacy database produces a delete event: op is d, before holds the deleted row (or at least
its key, see the next section) and after is null. By default the connector then emits a tombstone: a record with
the same key and a null value. The tombstone is meant for Kafka log compaction. In a compacted topic, it allows Kafka
to remove all earlier records with that key, so the topic does not keep deleted customers forever.
{ "key": { "CUST_ID": "1042" },
"value": { "before": { "CUST_ID": "1042", "CUST_NAME": "Ana Ruiz", "EMAIL": "ana@example.com", "STATUS_CD": "I" },
"after": null, "op": "d", "source": { "table": "CUSTOMER", "scn": "3108771" } } }
{ "key": { "CUST_ID": "1042" },
"value": null }
Reference: Debezium — Oracle delete events
One setting controls this behaviour on the source connector:
# true (default): emit a delete event followed by a tombstone
# false: emit only the delete event
tombstones.on.delete=true
For the migration, deletes have three practical consequences:
-
Consumers must handle a
nullvalue. A Spring Kafka listener that deserializes every value as a change event fails on the tombstone unless it checks fornullfirst. See Listening to Events in Applications. -
Sinks need to be told to apply deletes. The JDBC sink deletes rows only with
delete.enabled=true(which requiresprimary.key.modeto berecord_key,record_valueorrecord_header; the Bookshop sink usesrecord_key); see JDBC Sink Connector. -
When events are flattened with
ExtractNewRecordState, the delete event must be kept or rewritten deliberately withdelete.tombstone.handling.mode, otherwise the new database never sees the delete. See Event Flattening.
TRUNCATE is a separate operation (op t) that some connectors can emit; whether it is captured and whether the sink
applies it (truncate.enabled on the JDBC sink) must be decided explicitly, because a truncate on a legacy staging
table can wipe a mirror table.
Old row images
The before field of an update or delete event holds the row as it was before the change. It is what lets a consumer
see that a book’s PRICE went from 12.50 to 14.00, or detect which AUTHOR_ID a book used to have. Whether before is
complete depends on how much the database writes to its log, so this is a database setting, not a Debezium one:
| Database | Setting for a full before image |
|---|---|
Oracle |
Minimal supplemental logging on the database, plus |
PostgreSQL |
|
MySQL and MariaDB |
|
SQL Server |
CDC change tables always store the full previous row. |
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
Reference: Debezium — Preparing the Oracle database
ALTER TABLE BOOKSHOP.BOOK ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
ALTER TABLE BOOKSHOP.AUTHOR ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
ALTER TABLE BOOKSHOP.CUSTOMER ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
ALTER TABLE BOOKSHOP.ORDERS ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
ALTER TABLE BOOKSHOP.ORDER_LINE ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
ALTER TABLE BOOKSHOP.SUPPLIER_CATALOGUE ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
Reference: Debezium — Preparing the Oracle database
Full supplemental logging increases the volume of the redo logs. The official documentation recommends applying it
selectively, which in practice means only to the captured tables. For the reverse pipeline, the PostgreSQL tables that
bookshop-pg-source captures get the equivalent setting:
ALTER TABLE public.book REPLICA IDENTITY FULL;
ALTER TABLE public.book_author REPLICA IDENTITY FULL;
ALTER TABLE public.author REPLICA IDENTITY FULL;
Reference: Debezium — PostgreSQL replica identity
The JDBC sink does not need before (it upserts after and deletes by key). Consumers that compute differences,
audit trails or reconciliation reports do.
Transaction metadata
The legacy Bookshop application writes an order as one Oracle transaction: one ORDERS row and several ORDER_LINE
rows. Debezium emits one change event per row, on two different topics. Without extra information a consumer cannot
tell whether it has seen the whole order or only some of its lines. Transaction metadata supplies that information.
With provide.transaction.metadata=true the connector:
-
emits a
BEGINand anENDtransaction boundary event for every transaction to a separate topic, by default<topic.prefix>.transaction(legacy.transactionfor Bookshop; the name can be overridden withtopic.transaction); -
adds a
transactionblock to every data change event, with the transactionid, thetotal_orderof the event in the transaction, and thedata_collection_orderof the event among the events of its table in that transaction.
provide.transaction.metadata=true
# Optional: override the default topic name legacy.transaction
# topic.transaction=transaction
The END event lists how many events each table contributed. For an order with one header row and two lines it
looks like this:
{
"status": "BEGIN",
"id": "07000c00a7080000",
"ts_ms": 1794212412000,
"event_count": null,
"data_collections": null
}
{
"status": "END",
"id": "07000c00a7080000",
"ts_ms": 1794212412480,
"event_count": 3,
"data_collections": [
{ "data_collection": "FREEPDB1.BOOKSHOP.ORDERS", "event_count": 1 },
{ "data_collection": "FREEPDB1.BOOKSHOP.ORDER_LINE", "event_count": 2 }
]
}
Reference: Debezium — Oracle transaction metadata
And each data event of that transaction carries the matching transaction block:
{
"before": null,
"after": { "ORDER_ID": "900017", "LINE_NO": "2", "BOOK_ID": "31", "QTY": "1", "UNIT_PRICE": "14.00" },
"op": "c",
"transaction": {
"id": "07000c00a7080000",
"total_order": 3,
"data_collection_order": 2
}
}
Reference: Debezium — Change data event enrichment
The LegacyOrderProjector can use this to build purchase_order and order_line from a complete order: it
buffers events by transaction.id and writes the new rows in one PostgreSQL transaction once the END event has
arrived and it has received event_count events for that id. Without this, a projector that writes as events arrive
can briefly expose an order with only some of its lines in the new application.
Keep these limits in mind:
-
Metadata exists only for transactions that occur after the connector is deployed. Snapshot events have no
transactionblock. -
The transaction topic and the data topics are separate topics. Kafka does not order records across topics, so the
ENDevent can arrive before the last data event; the consumer must wait for both theENDevent and the full count, not for one of them. -
The data collection names in the
ENDevent include the database name (FREEPDB1.BOOKSHOP.ORDERSfor Oracle), so the consumer must match them to topics.
At-least-once delivery
Debezium’s default guarantee is at-least-once: no change is missed, but some records can be delivered more than once. The official exactly-once page states this directly, and the FAQ explains why consuming applications must expect duplicates.
Duplicates come from the gap between producing an event and recording the offset that says it was produced. Kafka
Connect commits source offsets periodically (every offset.flush.interval.ms, 60 seconds by default in the Debezium
Connect image), not per record. If the worker stops abruptly between two commits, the connector restarts from the last
committed offset and produces again the events that followed it. A graceful stop or rebalance flushes the offsets first,
so it normally causes no duplicates. A crash, a killed pod or an out-of-memory error does. Producer retries after a
network error can also write the same record twice when the producer is not idempotent.
The window of possible duplicates is bounded by the offset flush interval and by the amount of change between two
commits. Shortening offset.flush.interval.ms makes the window smaller but costs throughput; it never makes it zero.
Duplicates are also possible on the consumer side: a consumer that applies a record and crashes before committing its
own Kafka offset receives the record again.
How consumers deduplicate
Since duplicates can arrive, every consumer that writes to the new database must be idempotent: applying the same event twice must leave the same result as applying it once. There are two common techniques, and the Bookshop pipeline uses both.
Idempotent writes by key
For mirror tables and simple translations, write the row state, not the delta. An upsert keyed by the legacy primary
key is naturally idempotent: applying the same after image twice produces the same row, and deleting an already
deleted row does nothing. The JDBC sink does exactly this with insert.mode=upsert and primary.key.mode=record_key.
INSERT INTO book (id, isbn, title, price, currency, published_on, active, supplier_id, updated_at)
VALUES (:id, :isbn, :title, :price, :currency, :published_on, :active, :supplier_id, :updated_at)
ON CONFLICT (id) DO UPDATE
SET isbn = EXCLUDED.isbn,
title = EXCLUDED.title,
price = EXCLUDED.price,
currency = EXCLUDED.currency,
published_on = EXCLUDED.published_on,
active = EXCLUDED.active,
supplier_id = EXCLUDED.supplier_id,
updated_at = EXCLUDED.updated_at;
A replay can also deliver an older state after a newer one only if events are reordered, which does not happen within one key on one partition (see the ordering section below). A redelivered sequence is replayed in its original order, so the final state is the same.
A processed-change table
Upserts are not enough when an event triggers a side effect that must happen once, such as appending to an audit
trail, incrementing a counter or sending an e-mail from the new application. For those, the consumer records the
identity of each processed event in the processed_change table in the same database transaction as the side effect,
and skips events whose identity is already there.
CREATE TABLE processed_change (
source_table text NOT NULL,
source_position text NOT NULL,
processed_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (source_table, source_position)
);
The identity must come from the source, not from Kafka: a duplicate produced after a connector restart has a new
Kafka offset but the same source position. For Oracle with provide.transaction.metadata=true (the Bookshop
setting), the consumers use the identity tx:<commit_scn>:<transaction id>:<total_order>: the transaction id plus the
position of the event in its transaction is unique for every streamed event. For the second ORDER_LINE event above,
committed at SCN 3109415 (an illustrative value), that is tx:3109415:07000c00a7080000:3. The values are the same
when the connector re-emits the event. Snapshot reads have no transaction, so their identity falls back to
op:scn:txId:key: the operation r, the snapshot SCN, the absent transaction id (null) and the key; each row is read once per
snapshot. Without transaction metadata, streamed events use the same fallback, which is unique unless one transaction
changes the same row twice at the same SCN. Listening to Events in Applications
builds it from the event.
package com.example.bookshop.migration;
import org.springframework.jdbc.core.simple.JdbcClient;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@Component
public class ProcessedChangeGuard {
private final JdbcClient jdbc;
public ProcessedChangeGuard(JdbcClient jdbc) {
this.jdbc = jdbc;
}
/**
* Records the event and runs the action in the same transaction.
* Returns false, without running the action, if the event was already processed.
*/
@Transactional
public boolean applyOnce(String sourceTable, String sourcePosition, Runnable action) {
int inserted = jdbc.sql("""
INSERT INTO processed_change (source_table, source_position)
VALUES (:table, :position)
ON CONFLICT DO NOTHING
""")
.param("table", sourceTable)
.param("position", sourcePosition) // tx:commitScn:txId:totalOrder, or op:scn:txId:key for snapshot reads
.update();
if (inserted == 0) {
return false;
}
action.run();
return true;
}
}
Reference: Debezium — Change data event enrichment
The full consumer, including how the Kafka offset is committed after the database transaction, is in Listening to Events in Applications. The pattern is the same as the idempotent consumer described in Messaging Patterns in Practice.
Ordering
Debezium preserves the order that matters most for replication, per row, and nothing more by default:
-
Per key. The event key is the row’s primary key (or the columns set with
message.key.columns). All events for one row go to the same topic and, because Kafka partitions by key, to the same partition, in log order. TheBOOK_ID 31price change can never overtake the earlier title change of the same book. -
Per topic, with one partition. The official documentation recommends single-partition topics for change events. With one partition, all events of a table are totally ordered. With several partitions, events for different rows can be consumed out of order; events of the same row stay ordered.
-
Not across tables.
ORDERSandORDER_LINEare separate topics. A consumer reading both can receive anORDER_LINEbefore itsORDERSrow, even though the legacy application inserted the header first in the same transaction. Use transaction metadata to regroup the events, or design the projection so that the order of arrival does not matter (for example, create a placeholderpurchase_orderwhen a line arrives first).
Single message transformations that change the key or route several tables to one topic change these guarantees. The outbox event router, for example, keys events by aggregate id, which gives per-aggregate rather than per-row ordering; see Outbox Event Router.
Exactly-once delivery
Debezium has no deduplication layer of its own. When it runs as a source connector on Kafka Connect, though, it can take
part in Kafka Connect’s exactly-once support for source connectors, introduced by KIP-618 and built on Kafka
transactions. With exactly-once enabled, Connect writes the records of a batch and the source offsets for that batch in
one Kafka transaction. After a crash, the uncommitted transaction is aborted, so its records are never visible to
read_committed consumers, and the connector restarts from the offset committed with the last successful batch. The
redelivery window of the previous section disappears for the hop from Debezium to Kafka.
Requirements
The Debezium connectors that support Kafka Connect exactly-once delivery are MariaDB, MongoDB, MySQL, Oracle, PostgreSQL and SQL Server. The other requirements are:
-
Kafka Connect 3.3.0 or later, in distributed mode. Standalone workers cannot provide exactly-once.
-
Every worker in the cluster has
exactly.once.source.support=enabled. For an existing cluster, the Kafka documentation requires two rolling restarts: first withpreparing, then withenabled. -
The connector configuration has
exactly.once.support=required. -
transaction.boundarymust bepollfor all Debezium source connectors. That is the default, so it only needs to be set if it was overridden. -
On a secured Kafka cluster, the worker principal needs
WriteandDescribeon the transactional idconnect-cluster-<group.id>, and each connector needs access to its offsets topic, as listed in the Kafka Connect security section. -
Consumers must read with
isolation.level=read_committed; otherwise they also see records of aborted transactions.
group.id=bookshop-connect
exactly.once.source.support=enabled
{
"exactly.once.support": "required",
"transaction.boundary": "poll"
}
spring:
kafka:
consumer:
group-id: bookshop-legacy-sync
isolation-level: read-committed
With exactly.once.support=required, Connect refuses to start the connector if the worker cluster is not set up for
exactly-once, which is safer than silently running at-least-once. You can check a configuration before creating the
connector with PUT /connector-plugins/OracleConnector/config/validate.
Limits
Exactly-once on the source side is a real improvement for a migration, but it is not a reason to drop idempotent consumers:
-
It covers only the hop from the database to Kafka. A consumer that writes to PostgreSQL and then commits its Kafka offset can still apply a record twice if it fails between the two steps. Kafka transactions do not include PostgreSQL. The JDBC sink connector and the Spring Boot consumers must stay idempotent.
-
Correctness concerns are documented. The official Debezium page notes that no comprehensive study has verified Kafka’s transaction implementation in recent releases. It cites Jepsen reports on other Kafka-compatible systems and open Kafka issues (KAFKA-17734, KAFKA-17754, KAFKA-17582) that may also affect Kafka Connect exactly-once.
-
Snapshots are not resumable. An initial snapshot that is interrupted is started again from the beginning, so its
revents can appear again in already committed transactions. Upserts by key handle this. -
It costs throughput and adds operational state. Transactions add latency per batch, and the cluster must be configured on every worker before any connector can use it.
A reasonable default for the Bookshop migration is: enable exactly-once on the Connect cluster for the Oracle source to remove most duplicates, and keep every consumer idempotent anyway. The details of offsets, restarts and the exactly-once set-up for the whole pipeline are in Offsets, Restarts & Exactly-Once.
Summary of guarantees
| Property | What Debezium provides | What the pipeline must add |
|---|---|---|
Completeness |
Every committed change after the snapshot position, plus a consistent snapshot |
Log retention longer than any outage, durable offsets and schema history, correct include lists |
Deletes |
Delete events and, by default, tombstones |
Sinks and consumers configured to apply deletes and to accept |
Old values |
|
Supplemental logging (Oracle), |
Transactions |
|
Consumers that buffer by transaction when they need complete aggregates |
Delivery |
At-least-once; exactly-once to Kafka on Kafka Connect with KIP-618 |
Idempotent consumers, |
Ordering |
Per row (per key); per table with single-partition topics |
No assumptions about order across tables or partitions |