Repository navigation
Clarify RDI snapshot modes and missed deletes #4238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b85be81
48a06a3
2c2504a
f6d2bb1
e4bb092
d87ebb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| A new snapshot copies existing source rows. It does not replay missed deletes or remove | ||
| target records for rows absent from the snapshot. | ||
|
|
||
| The timeline shows one row whose delete event is lost before collection resumes. | ||
| Time progresses from top to bottom. | ||
|
|
||
| ```mermaid | ||
| %%{init: {"sequence": {"actorMargin": 15, "diagramMarginX": 5, "width": 90, "mirrorActors": false}}}%% | ||
| sequenceDiagram | ||
| participant Source as Source<br/>database | ||
| participant RDI as RDI<br/>collector | ||
| participant Redis as Target<br/>Redis | ||
|
|
||
| Source->>RDI: Capture<br/>row 42 | ||
| RDI->>Redis: Write<br/>row 42 | ||
| Note over RDI: Collection stops | ||
| Note over Source: Delete row 42 | ||
| Note over Source,RDI: Required log<br/>history expires | ||
| RDI->>Source: Restart with<br/>when_needed | ||
| Note over Source,RDI: Saved position unavailable<br/>New snapshot | ||
| Source->>RDI: Current rows<br/>(without row 42) | ||
| RDI->>Redis: Write snapshot<br/>rows | ||
| Note over Redis: Row 42 is stale<br/>Delete missed | ||
| ``` | ||
|
|
||
| An interruption alone does not cause this gap. If the saved position and the required | ||
| log history are still available, the collector can resume and capture the delete. | ||
| In this example, the history expires before the collector resumes, and the new snapshot | ||
| contains no row 42 to overwrite or delete its target record. Streaming resumes after | ||
| the snapshot, but the stale record can remain in Redis. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| The collector saves an *offset*, which is its position in the source's change history. | ||
| A missing offset means there is no saved position, as on first deployment or after a | ||
| reset. An unavailable position means an offset exists, but the source no longer has | ||
| the log history needed to resume from it. | ||
|
|
||
| With the default `initial` mode, the collector snapshots when there is no saved | ||
| position, then streams changes. A restart with a completed snapshot and a valid saved | ||
| position resumes streaming. Deployment or restart alone does not require a new snapshot. | ||
| If the saved position is no longer available, `initial` does not automatically | ||
| re-snapshot to recover, and the collector stops and reports an error. | ||
|
|
||
| With `when_needed` mode, the collector also takes a new snapshot when it detects that the | ||
| saved position is no longer available. This can reload all selected data after an | ||
| outage without a manual reset. The snapshot captures current rows, rather than | ||
| reconstructing every missed change. | ||
|
ZdravkoDonev-redis marked this conversation as resolved.
|
||
|
|
||
| If the collector restarts during a snapshot, the snapshot starts again. Rows deleted | ||
| while the snapshot is interrupted can remain as stale records in the target because | ||
| the new snapshot does not replay their delete events. | ||
|
|
||
| Use `when_needed` with monitoring and alerting. Recovery can start a long-running | ||
| snapshot, which can increase latency and leave stale target records until recovery | ||
| finishes. | ||
|
|
||
| #### Missed deletes can leave stale target records {#missed-deletes} | ||
|
|
||
| {{< embed-md "rdi-snapshot-gap.md" >}} | ||
|
|
||
| #### Compare snapshot modes | ||
|
|
||
| The available modes and their exact behavior depend on the source connector and its | ||
| version. The following table describes the six values listed in the RDI configuration | ||
| reference. A listed value is not necessarily supported by every connector. | ||
|
|
||
| | Mode | Existing source data | Restart with a saved position | After a reset clears the position | | ||
| | :-- | :-- | :-- | :-- | | ||
| | `initial` (default) | Snapshot when no offset exists, then stream changes. | Resume after a completed snapshot if the position is valid. No automatic snapshot recovery for unavailable log history. | Snapshot, then stream changes. | | ||
| | `when_needed` | Snapshot when no offset exists, then stream changes. | Resume if the position is valid. Snapshot again if the connector detects an unavailable position. | Snapshot, then stream changes. | | ||
| | `always` | Snapshot on every collector start, then stream changes. | Take a new snapshot even if the position is valid. | Snapshot, then stream changes. | | ||
| | `initial_only` | Take an initial snapshot without streaming subsequent changes. | Restart an interrupted initial snapshot; do not capture subsequent changes after it completes. | Snapshot without ongoing change capture. | | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may be worth noting that using
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why would
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With |
||
| | `no_data` | Skip existing rows. Initialize any required schema or source position, then stream changes. | Resume streaming if the position is valid. No data snapshot to recover unavailable history. | Skip existing rows and start streaming according to the connector's rules. | | ||
| | `never` | Skip the data snapshot where this mode is supported. | Resume according to the connector's rules; no data snapshot recovery. | Connector-specific startup behavior; existing rows are not reloaded. | | ||
|
|
||
| An interrupted initial snapshot can restart when the collector starts again, including | ||
| with `initial` and `initial_only`. | ||
|
ZdravkoDonev-redis marked this conversation as resolved.
|
||
|
|
||
| For Debezium 3.5, note these connector differences: | ||
|
|
||
| - PostgreSQL `no_data` performs no snapshot. It resumes from a saved log sequence | ||
| number (LSN), or from the replication slot's creation position when no LSN is saved. | ||
| This requires the relevant write-ahead log (WAL) history to remain available. | ||
| - Other connectors can capture schema or initialize a position without copying | ||
| existing rows in `no_data` mode. | ||
| - `never` is a deprecated alias for `no_data` in PostgreSQL and MongoDB. MySQL and | ||
| MariaDB retain `never` with connector-specific prerequisites. Oracle and SQL Server | ||
| do not offer `never`; use `no_data` to skip existing rows. | ||
|
|
||
| See the Debezium 3.5 connector references for [MariaDB](https://debezium.io/documentation/reference/3.5/connectors/mariadb.html), | ||
| [MongoDB](https://debezium.io/documentation/reference/3.5/connectors/mongodb.html), | ||
| [MySQL](https://debezium.io/documentation/reference/3.5/connectors/mysql.html), | ||
| [Oracle](https://debezium.io/documentation/reference/3.5/connectors/oracle.html), | ||
| [PostgreSQL](https://debezium.io/documentation/reference/3.5/connectors/postgresql.html), | ||
| and [SQL Server](https://debezium.io/documentation/reference/3.5/connectors/sqlserver.html). | ||
Uh oh!
There was an error while loading. Please reload this page.