Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 70 additions & 3 deletions skills/connect-cdc-mongodb/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ description: >-
Streams change data capture from MongoDB into Redpanda or Kafka using Redpanda
Connect's mongodb_cdc input, built on MongoDB Change Streams over a replica set or
sharded cluster. Use when configuring mongodb_cdc, setting up Change Streams,
enabling an initial snapshot before live streaming, choosing between update_lookup
enabling an initial or incremental snapshot alongside live streaming, backfilling a
collection on demand through a signal collection, choosing between update_lookup
and pre_and_post_images document modes, or checkpointing with resume tokens in a
cache resource. Also covers Redpanda Enterprise destination features like Iceberg
Topics, Tiered Storage, and server-side Schema ID Validation, all of which require a
Expand Down Expand Up @@ -175,7 +176,71 @@ Rules that matter when choosing this path:

Per-field detail (`region`, `session_duration`, `id`/`secret`/`token`, `role`/`role_external_id`, `roles[]`) is in [Config Reference](references/config-reference.md) and the generated connector reference.

### Snapshot Phase
### Snapshot Modes

Since Connect 4.116.0 there are three ways existing documents are read, and the first two are
**mutually exclusive snapshot modes** — setting both `stream_snapshot: true` and
`incremental_snapshot.enabled: true` is rejected at startup, because both read the same documents
and enabling both would deliver everything twice.

| Mode | How it reads | Pick it when |
|---|---|---|
| `stream_snapshot: true` | An up-front snapshot of every collection, then streaming | You want the backfill complete before any change is delivered |
| `incremental_snapshot.enabled: true` | Collections are read in `_id`-ordered chunks **alongside** streaming, from the start | Streaming must not wait for a large backfill |
| A `snapshot-execute` signal | Reads the named collections in chunks alongside streaming, on demand | You are adding a collection, or re-reading one, on a running pipeline |

The third works in **every** snapshot mode: `incremental_snapshot.enabled` is not required for a
signal to queue a read. The rest of the `incremental_snapshot` block (chunk size, the progress
cache key, the retry cooldown) governs signal-requested reads too.

Incremental reads are chunked and each chunk is released once the change stream has caught up with
the moment it was read, so a chunk that a live write superseded is dropped rather than reverting
it. Progress is stored in `checkpoint_cache` under `incremental_snapshot.checkpoint_cache_key`,
separate from the stream position, so a restart continues from the last acknowledged chunk.

Two constraints the input enforces at startup: `incremental_snapshot.checkpoint_cache_key` must
differ from `checkpoint_key` (the two are stored separately), and
`incremental_snapshot.chunk_size` must not exceed `checkpoint_limit` — a chunk goes in flight as a
whole, so a larger one stalls streaming until everything before it is acknowledged.

Read the field types, defaults and the full block from the generated reference or
`rpk connect create mongodb_cdc`.

### Signal Collection

`signal_collection_name` names a collection in `database` that the input watches for control
documents while it runs. Each is `{"type": ..., "data": ...}`, where `data` may be a subdocument or
a JSON string: `log` logs `data.message`, and `snapshot-execute` queues a chunked read of the
collections it names. MongoDB has collections rather than tables, so the payload accepts
`collections` alongside the shared `tables` key, and the two are merged:

```javascript
db.connect_signals.insertOne({
type: "snapshot-execute",
data: { collections: ["orders"] }
})
```

Four traps, each enforced or logged by the connector:

- **The signal collection must not be one of the streamed `collections`.** The input rejects that
config at startup — its own inserts would be read back as signals.
- **Signal inserts are also emitted as ordinary messages**, with `collection` metadata set to the
signal collection. Filter them out downstream if you do not want them in the topic.
- **A signal naming a collection that is not in `collections` is rejected**, logged at error, and
nothing else reports it — the stream carries on. Nothing outside the watched set can be
deduplicated against the chunks, which is why it is refused. A collection already queued or
being read is skipped and logged at info, not an error.
- **Progress is only kept current while `incremental_snapshot.enabled` is true or a
`signal_collection_name` is set.** With neither, the input discards what is stored under the
progress key, and enabling either later will not resume a read the stream has long since moved
past.

Unlike `postgres_cdc`, pointing `incremental_snapshot.checkpoint_cache_key` at a fresh key does
**not** cause a new read: with a stream position stored, a restart treats every collection as
already read. Re-reading a collection takes a `snapshot-execute` signal.

### Up-front Snapshot Phase

When `stream_snapshot: true` and no resume token is cached, the connector snapshots all documents in each collection before streaming live changes.

Expand Down Expand Up @@ -238,7 +303,9 @@ When a stored position can no longer be resumed from (aged out of the oplog, or

### Restart Behavior

On restart with a valid cached token, the connector immediately opens the change stream at the stored position — no snapshot is performed regardless of the `stream_snapshot` setting. The snapshot only runs when no checkpoint exists; because the completed snapshot's position is now checkpointed once fully acknowledged, a restart after a finished snapshot resumes the stream rather than snapshotting again.
On restart with a valid cached token, the connector immediately opens the change stream at the stored position — no **up-front** snapshot is performed regardless of the `stream_snapshot` setting. That snapshot only runs when no checkpoint exists; because the completed snapshot's position is now checkpointed once fully acknowledged, a restart after a finished snapshot resumes the stream rather than snapshotting again.

An incremental read is the exception: a restart resumes it from the last acknowledged chunk, since its progress is checkpointed separately under `incremental_snapshot.checkpoint_cache_key`. A `snapshot-execute` signal is checkpointed into the queue before the transaction carrying it is acknowledged, so a restart does not lose a read that was requested but not yet started.

### Scaling

Expand Down
52 changes: 51 additions & 1 deletion skills/connect-cdc-mongodb/references/SOURCES.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ they belong to other skills' domains and are cited here only as pairing context.

| Skill file | redpanda-data/connect source paths | rp-connect-docs sources |
|---|---|---|
| `SKILL.md` | `internal/impl/mongodb/cdc/input.go` (config spec, `newMongoCDC`, `license.CheckRunningEnterprise`, checkpoint/snapshot/streaming logic, metadata keys), `internal/impl/mongodb/cdc/schema.go` (schema metadata, `normaliseDecimal128`), `internal/impl/mongodb/cdc/checkpoint_cache.go`, `internal/impl/mongodb/common.go` (connection/URL/auth/driver timeouts) | `modules/components/pages/inputs/mongodb_cdc.adoc` (auto-generated); `docs-data/overrides.json` (`mongodb_cdc` entry) |
| `SKILL.md` | `internal/impl/mongodb/cdc/input.go` (config spec, `newMongoCDC`, `license.CheckRunningEnterprise`, checkpoint/snapshot/streaming logic, metadata keys), `internal/impl/mongodb/cdc/incremental_snapshot.go` (chunked read alongside streaming, `incSnapshotRun.request`), `internal/impl/mongodb/cdc/signalling.go` (`decodeMongoSignal`, `parseSnapshotCollections`, `handleSignal`), `internal/replication/signalling.go` (`LogSignalType`, `SnapshotSignalType`, `SnapshotSignal`), `internal/replication/incrementalsnapshot/coordinator.go` (chunk/window algorithm), `internal/impl/mongodb/cdc/schema.go` (schema metadata, `normaliseDecimal128`), `internal/impl/mongodb/cdc/checkpoint_cache.go`, `internal/impl/mongodb/common.go` (connection/URL/auth/driver timeouts) | `modules/components/pages/inputs/mongodb_cdc.adoc` (auto-generated); `docs-data/overrides.json` (`mongodb_cdc` entry) |
| `references/config-reference.md` | `internal/impl/mongodb/cdc/input.go` (every field: `url`, `database`, `username`, `password`, `app_name`, `collections`, `checkpoint_*`, `read_*`, `stream_snapshot`, `snapshot_parallelism`, `snapshot_auto_bucket_sharding`, `document_mode`, `json_marshal_mode`, `auto_replay_nacks`; `$match` filter; driver timeouts), `internal/impl/mongodb/cdc/schema.go` (`normaliseDecimal128`, `schema.BigDecimal` contract) | `modules/components/pages/inputs/mongodb_cdc.adoc` (field list + defaults — **auto-generated, source of record**); `docs-data/overrides.json` |
| `references/setup-mongodb.md` | `internal/impl/mongodb/cdc/input.go` (startup `{hello:1}` check, `lastWrite.majorityOpTime.ts` / `isdbgrid` / `getCurrentResumeToken`, version `< 4` error string, `splitVector` / `$bucketAuto` snapshot paths, error messages) | `modules/components/pages/inputs/mongodb_cdc.adoc` |
| `references/pipeline-and-output.md` | `internal/impl/mongodb/cdc/input.go` (message body per `document_mode`, metadata keys `operation`/`collection`/`operation_time`/`schema`, resume/restart semantics, `ResumeAfter`), `internal/impl/mongodb/cdc/schema.go` (Decimal128 normalization) | `modules/components/pages/inputs/mongodb_cdc.adoc`; cache-resource and `redpanda`/`kafka_franz` output pages under `modules/components/pages/` (see TODO) |
Expand All @@ -44,6 +44,12 @@ they belong to other skills' domains and are cited here only as pairing context.

## TODO / re-verify

- **`references/pipeline-and-output.md` and `references/config-reference.md` predate the v4.116.0
incremental snapshot mode.** `SKILL.md` now carries the modes, the signal contract and the
enforced constraints, and `pipeline-and-output.md`'s restart/resume prose still describes only
the up-front snapshot. Fold the incremental and signal paths into those two files on the next
pass, or leave them to the docs if this skill is converted to the thin format first.

- **Skill cites a wrong docs path:** `config-reference.md` and `setup-mongodb.md` reference the generated page as `connect/docs/modules/components/pages/inputs/mongodb_cdc.adoc`. The published page actually lives in **`rp-connect-docs`** at `modules/components/pages/inputs/mongodb_cdc.adoc` (no `connect/docs/` prefix). The Go docstrings that feed generation are in `connect/internal/impl/mongodb/cdc/input.go`. Correct the skill's citation.
- **Enterprise topic/cluster properties** (`iceberg_enabled`, `redpanda.iceberg.*`, `enable_schema_id_validation`, `redpanda.{key,value}.schema.id.validation`, `redpanda.{key,value}.subject.name.strategy`, `redpanda.remote.{read,write,delete}`, `retention.local.target.{ms,bytes}`) in `enterprise-integration.md` are **broker** properties, not Connect. Citation of record: `redpanda-data/docs` property partials (`topic-properties.adoc`, `cluster-properties.adoc`, `object-storage-properties.adoc`), upstream `redpanda-data/redpanda` `src/v/config/configuration.cc`. Not verified this session.
- **Licensing / Schema ID Validation prose** (`licensing/overview.adoc`, `schema-reg/schema-id-validation.adoc`) live in `redpanda-data/docs`, not Connect — not verified this session.
Expand All @@ -53,6 +59,50 @@ they belong to other skills' domains and are cited here only as pairing context.

## Sync log

- **Verified against Connect v4.118.0 (2026-11-13 sync).** One new structural surface: `mongodb_cdc`
gained an incremental snapshot mode and a signal collection at **v4.116.0**, neither of which the
skill covered. Grounded at tag `v4.118.0` in `internal/impl/mongodb/cdc/input.go` (the field
constants `incremental_snapshot` with `enabled` / `chunk_size` / `checkpoint_cache_key` /
`retry_cooldown`, and `signal_collection_name`; their `Description` strings; and the startup
checks in the config parse), `internal/impl/mongodb/cdc/signalling.go` and
`internal/replication/signalling.go`.
- **Two mutually exclusive snapshot modes.** `stream_snapshot` and
`incremental_snapshot.enabled` are rejected together at startup — "are mutually exclusive
snapshot modes, only one can be enabled" — because both read the same documents. The
incremental mode reads collections in `_id`-ordered chunks alongside the stream with no up-front
phase, releasing each chunk once the stream has caught up with the moment it was read.
- **A `snapshot-execute` signal works in every snapshot mode**, `incremental_snapshot.enabled`
included or not; the field's own description says so, and `handleSignal` queues on the run that
"every connection with a signal collection has, whatever the snapshot mode". The payload accepts
`collections` **and** the shared `tables` key, merged by `parseSnapshotCollections`.
- **The four traps taken into the skill**, each from an enforced check or a log line:
`signal_collection_name` must not name a streamed collection ("its inserts are read as
signals"); signal inserts are also emitted as ordinary messages with `collection` metadata set
to the signal collection (stated in the field description); a signal naming a collection outside
`collections` is rejected and only logged at error while the stream continues
(`handleSignal`), and one already queued or being read is logged at info; and with neither
`enabled` nor a signal collection the stored progress is discarded (the "Discarding the
incremental snapshot progress stored under %s" log).
- **Two startup constraints**, both from the config parse: `incremental_snapshot.checkpoint_cache_key`
must differ from `checkpoint_key`, and `incremental_snapshot.chunk_size` must not exceed
`checkpoint_limit` ("a chunk is in flight as a whole").
- **Contrast with `postgres_cdc` taken from the field description verbatim in substance:** a new
`checkpoint_cache_key` does *not* cause a new read in `mongodb_cdc`; re-reading a collection
takes a signal.
- **`references/pipeline-and-output.md` Restart Behavior was drifted** by the same change — it
said no snapshot runs on restart "regardless of the `stream_snapshot` setting", which is still
true of the up-front snapshot but not of an incremental read (resumed from its own progress key)
or of a queued signal (checkpointed into the queue before the carrying transaction is acked).
Corrected in `SKILL.md`; see the TODO below for the reference file.
- **Deliberately deferred:** the field types, defaults and the full `incremental_snapshot` block
stay in the generated reference and `rpk connect create mongodb_cdc`. The skill documents the
modes, the signal contract and the enforced constraints only.
- **Also in the window, deliberately not documented:** the `v4.116.0` fix to snapshot-signal
behavior across all modes and for collections unknown to stored progress (`#5066`), and the
`v4.118.0` fix making the incremental snapshot wait for the majority snapshot to reach the
stream start (`#5132`). Both are corrections to the behavior the skill now describes, with no
separate config or decision surface.

- **Verified against Connect v4.106.0 (2026-08-21 sync).** New sources for this release:
- `internal/impl/mongodb/common.go` — `AWSIAMAuthField()` (the shared `aws` block spec: `enabled`, `region`, `session_duration`, `id`/`secret`/`token`, `role`/`role_external_id`, `roles[]`), plus the startup errors rejecting `username`/`password` and url-embedded credentials when `aws.enabled` is true, and the note that the processor and cache reject role/session credentials (no refresh path).
- `internal/impl/mongodb/aws/aws.go` — the `MONGODB-AWS` credential builder; registered in `public/components/aws/package.go`.
Expand Down
12 changes: 9 additions & 3 deletions skills/connect-cdc-oracle/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,16 @@ prefetch_rows: 5000

A `PREFETCH_ROWS` query parameter on `connection_string` still works and **takes precedence** over the field (matched case-insensitively), so remove it if you want the field to apply. Values of `0` or below are rejected — both by `rpk connect lint` and at startup.

**Redo log retention must cover idle periods, not just outages.** The SCN checkpoint only advances when messages are delivered, so a monitored table set that goes quiet leaves the checkpoint stationary while Oracle ages out redo/archive logs. If the checkpointed SCN is gone when activity resumes or the pipeline restarts, the input cannot resume and fails repeatedly with **ORA-01292**. Therefore:
**Redo log retention must cover open transactions and outages.** Since Connect 4.117.0 the checkpoint advances roughly every 10 seconds once every delivered batch has been acknowledged, **including while the monitored tables are idle** — the input marks the mined position after a mining cycle that produced no rows. A quiet table set therefore no longer pins the checkpoint while Oracle ages out redo/archive logs. (Before 4.117.0 only a delivered message moved it, so an idle table set left it stationary; if you are pinned to an earlier release, size retention for the longest idle period instead.) Three things still hold the checkpoint back:

- Size archive log retention to exceed the longest plausible **idle** period for the monitored tables — not just the longest expected downtime.
- Alert on a **stagnant checkpoint SCN** and on repeated ORA errors; a stationary checkpoint under a quiet workload is indistinguishable from a healthy one until the logs age out.
- It **never moves past the start of a transaction that is still open**, so one long-running transaction pins the resume position for as long as it stays open.
- On an idle database it can trail the current SCN by up to `logminer.min_scn_window_size` SCNs, because the input does not mine a range smaller than that.
- With a `batching.count` policy and no `batching.period`, rows wait in the batcher until more rows arrive and the checkpoint does not advance until they flush. **Set a `period` on any count-based batching policy**, or a quiet pipeline stops checkpointing for a different reason.

Therefore:

- Size archive log retention to exceed the longest open transaction plus the longest plausible pipeline outage. If the checkpointed SCN is gone when the pipeline restarts, the input cannot resume and fails with **ORA-01291**.
- Alert on a **stagnant checkpoint SCN** and on repeated ORA errors. A checkpoint that is not moving now means an open transaction, a count-only batching policy, or a stalled pipeline — not merely a quiet one.
- On databases with infrequent log switches, watch for **ORA-04036** (LogMiner PGA growth) and bound it with `logminer.max_session_age`.
- On a CDB whose shared SCN is advanced by another PDB, the default `scn_window` strategy grows its window over mostly-empty SCN ranges. Switch `logminer.window_strategy` to `redo_volume` to size each cycle by the redo actually read instead — see [config-reference.md](references/config-reference.md).
- A **flashback or point-in-time recovery followed by `OPEN RESETLOGS`** looks like the same failure but is not a retention problem: it starts a new database incarnation, so a checkpoint taken before the reset can never be resumed and the input fails with **ORA-01291** no matter how much retention you add. Recovery is to delete the checkpoint entry — with the default Oracle-based cache the flashback rolls the row *back* rather than clearing it, so it must be deleted explicitly — and to set `snapshot_mode: snapshot_and_stream` in the same change, since a checkpoint that is still present skips snapshotting entirely.
Expand Down
Loading
Loading