procedure Data & storage
Change-data-capture offsets and replays
A CDC checkpoint tells a consumer where to resume, not which effects survived. Compare it with durable effects and retained history to distinguish a harmless reread from a repeated effect, skipped work, or a gap.
What it means
A change-data-capture (CDC) consumer uses a checkpoint to decide where to resume reading after an interruption. The checkpoint records progress through the stream; it does not, by itself, prove which changes took effect at the destination. If the destination is ahead of the checkpoint, the consumer may repeat work. If the checkpoint is ahead of the destination, the consumer may skip work.
In this example, an offset is an event number, and a checkpoint of 3 means the consumer has recorded events through 3 as complete. Its next read starts at 4. A separate marker, the durable effect prefix, tells you how far the destination actually got: a prefix of 5 means the effects of all events through 5 survived the interruption.
Try it
Simulation: The source retains events 2 through 8. Start with the checkpoint at 3 and durable effects through 5. On the offset ruler, follow the restart arrow to 4. There are five events to read, 4 through 8, but only three whose effects are new: 6, 7, and 8. With Idempotent repeated effects set to yes, reading 4 and 5 again adds no effects for those events.
Change-data-capture offsets and replays
Explain replayable change streams and idempotent consumers across reconnect
Required retained events can be read again; idempotency determines repeated effects in the model.
Restart result
- Branchreplay
- Remaining events5
- Repeated events2
- Repeated effects0
- Deduplicationyes
Offsets are synthetic inclusive prefixes; the restart starts at checkpoint plus one. Skip risk takes precedence over expired history. Idempotency affects only repeated effects and is not inferred if unevaluated.
Evaluated inputs
- Required scenario evidence
- provided
- Checkpoint observation
- known
- Last durable checkpoint
- 3 offset
- Last durable effect prefix
- 5 offset
- Last source event
- 8 offset
- Earliest retained event
- 2 offset
- Idempotent repeated effects
- yes
Contiguous synthetic offsets and durable prefix; checkpoint means last completed offset, not a Kafka next-offset convention or PostgreSQL LSN. Dedup is stipulated and only applies to repeated effects; no transaction/broker implementation. Skip-risk takes precedence over expired when checkpoint already exceeds effects. Actual history and checkpoint require read-only observation.
About this model
The controls set only a local, bounded scenario. The computed branch is not a verdict about a live system. Inputs listed as not evaluated did not participate in this branch after validation.
Reset restores the original inputs. It does not change the open or closed state of help or FAQ answers.
Change only Idempotent repeated effects to no. The restart arrow stays at 4, and the consumer still rereads two already-applied events. What changes is the destination: it now gets two repeated effects instead of zero. Idempotency changes what a second application does, not which event the consumer reads next. Use Reset to return to the original example.
What survives the interruption
The two markers answer different questions because saving an effect and acknowledging progress need not happen together. In the starting example, the effects for 4 and 5 survived, but the checkpoint covering them did not. PostgreSQL 18's logical decoding documentation describes a related case: after a crash, a replication slot can return to an earlier position and send recent changes again. A second delivery need not represent a second source change.
Now consider the opposite order. Keep the durable effect prefix at 5 but put the checkpoint at 6. A restart would begin at 7, leaving events 7 and 8 to read. The effect of event 6 would be skipped, even though event 6 is still in the log. STOP and reconcile that discrepancy. Protection against repeated effects cannot help with an event the consumer will not read.
Retention is a separate check. With the checkpoint back at 3, it is event 4, not event 3, that must still be available. If 4 is the earliest retained event, the restart can read the entire required interval. If 5 is the earliest, one required event is missing. That does not mean the effect of 4 was lost; in this example it was durable. It means the consumer cannot replay the interval its checkpoint calls for. The simulation stops rather than moving the restart arrow past the gap.
The offset diagram also distinguishes two reasons to stop. If the checkpoint is 6, durable effects end at 5, and the earliest retained event is 8, the model first reports a skipped effect at 6. It does not repair that missing effect by starting at the retained offset. The skip-risk branch takes precedence; the history gap still requires reconciliation.
In practice
Before considering a real replay, use authorized read-only access to establish three facts for the same stream and destination:
- Find the durable checkpoint and confirm what it means on the deployed version. Does it name the last completed event or the next position to read? Do not apply the example's “add one” rule to a Kafka next offset or a PostgreSQL log sequence number (LSN).
- Check the destination independently. Identify which effects are known to be durable and, for any overlap with the proposed replay, what would prevent applying those effects twice. An acknowledgment is not a substitute for this evidence.
- Verify that the source can supply the required history. For PostgreSQL, check the replication slot and the availability of the required write-ahead log (WAL), not just the saved LSN. Check the installed minor version as well: the PostgreSQL 18.7 release notes describe logical-decoding fixes involving aborted subtransactions and snapshot handling. A position alone is not proof of a complete change history.
If the checkpoint, required history, destination state, or applicable version is unknown, STOP rather than guessing a restart position. If history is missing or effects were skipped, use the system's supported reconciliation or recovery procedure to establish a consistent starting point. The simulation changes no service or stored data. Any proposed real change needs separate authorization, a preserved before-state, and a plan to verify the result and recover if it differs.
A replay decision needs two kinds of evidence: that the source can supply what the consumer will read, and that the destination can account for what it already did. A saved offset alone establishes neither safe replay nor exactly-once effects.
Frequently asked questions
Editorial questions based on the listed sources and explicitly labeled local examples.
Does rereading an event mean the source created it twice?
No. A retained change can be delivered again after recovery. PostgreSQL logical decoding documents possible repeats after a crash.
What if the needed log is no longer retained?
You cannot infer safe replay from a numeric checkpoint alone. Stop and establish a new consistent starting point, possibly via a supported snapshot/reconciliation procedure.
Can effect and checkpoint commit atomically?
Within a suitably coordinated transaction, sometimes yes. External effects require their own coordination or idempotency; an offset commit alone cannot guarantee them.
Does a durable checkpoint prove all prior effects are durable?
No. In this example a checkpoint can advance beyond the destination’s durable effect prefix. Restarting there would omit the missing effects. Establish both prefixes and retained history before choosing a supported recovery method; deduplication alone cannot recover skipped events.
Sources & model boundaries
Primary references used for this explanation. The interactive example is an educational model, not a live check.
- PostgreSQL logical decoding concepts
Logical decoding concepts. Logical decoding extracts WAL changes; a crash can return a slot to earlier position and resend recent changes. Consumers must handle duplicate effects.
Checked .
- Apache Kafka design: message delivery semantics
consumer position. Atomic offsets and output topics can support scoped exactly-once processing; external outputs require coordination.
Checked .
- PostgreSQL 18: replication settings
19.6.1 max_slot_wal_keep_size. Required WAL can be removed when a retained slot falls beyond a configured bound; slot availability needs evidence.
Checked .
- PostgreSQL 18.7 release notes
E.1.2 Changes: logical decoding and snapshot fixes. 18.7 corrects logical-decoding subtransaction-abort handling and a snapshot race.
Checked .