You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "GabrielBBaldez (via GitHub)" <gi...@apache.org> on 2026/06/10 13:12:33 UTC
[PR] [Feature][Connector-V2][MongoDB-CDC] Support latest-offset startup mode without initial snapshot [seatunnel]
GabrielBBaldez opened a new pull request, #11053:
URL: https://github.com/apache/seatunnel/pull/11053
### Purpose of this pull request
Closes #11051. Related user report: #9511.
Adds an explicit `latest` startup mode to `MongoDB-CDC`, so a job can skip the initial snapshot and consume only changes made after it starts.
### What changed
**Option (`MongodbIncrementalSourceOptions`)**
- `startup.mode` now accepts `latest` (choices: `initial`, `latest`, `timestamp` — was `initial`, `timestamp`).
- Fixed the stale description, which advertised `earliest`/`specific` values the connector never accepted; it now describes exactly what each supported mode does.
**Why no runtime changes were needed**
The cdc-base runtime already implements the requested semantics — this connector just never exposed the mode:
- `IncrementalSource#createEnumerator` routes any non-`INITIAL` mode to `IncrementalSplitAssigner` (stream-only), so the snapshot/copy phase is skipped entirely.
- `StartupConfig#getStartupOffset(LATEST)` resolves the start position through `ChangeStreamOffsetFactory#latest()`, which MongoDB-CDC already implements (current change-stream position).
- Restore goes through the same checkpoint path: an `IncrementalPhaseState` checkpoint restores into `IncrementalSplitAssigner`, so a restarted job resumes from the checkpointed change-stream position and never falls back into a snapshot.
**Tests (`MongodbIncrementalSourceFactoryTest`)**
- Updated the option-rule test to assert the supported startup modes are exactly `initial`, `latest`, `timestamp`.
- New test proving `StartupMode.LATEST` resolves through `ChangeStreamOffsetFactory` to a `ChangeStreamOffset` positioned at the current time (timestamp set, no resume token) — i.e. "new changes only".
**Docs (EN + ZH)**
- Documented `startup.mode` and `startup.timestamp` in the options table (they were previously undocumented).
- Added a "Startup Mode" section explaining the three modes, checkpoint/restore behavior, and a `startup.mode = "latest"` example job.
### Scope notes (matching the issue's non-goals)
- No dynamic newly-added collection discovery, no new metadata keys.
- `earliest` is intentionally **not** exposed: `ChangeStreamOffsetFactory#earliest()` currently returns the current timestamp (same as `latest`), so advertising it would be misleading.
### Verification
- `mvn test -pl seatunnel-connectors-v2/connector-cdc/connector-cdc-mongodb` — 17/17 passing (JDK 11).
- `mvn spotless:apply` clean.
### Check list
* [x] Code changed are covered with tests, or it does not need tests for reason
* [ ] If any new Jar binary package adding in your PR, please add License Notice according [New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
* [x] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2][MongoDB-CDC] Support latest-offset startup mode without initial snapshot [seatunnel]
Posted by "dheerusri324 (via GitHub)" <gi...@apache.org>.
dheerusri324 commented on PR #11053:
URL: https://github.com/apache/seatunnel/pull/11053#issuecomment-4671366093
Hi @GabrielBBaldez, as @DanielLeens mentioned, I was testing this locally and hit the exact same MongodbConnectorException blocker.
The issue is that the actual builder guard was never updated to accept the new mode. The fix is right inside MongodbSourceConfigProvider.java (which isn't in your PR yet).
If you update MongodbSourceConfigProvider.java with this snippet, it bypasses the block:
public Builder startupOptions(StartupConfig startupOptions) {
this.startupOptions = Objects.requireNonNull(startupOptions);
if (startupOptions.getStartupMode() != StartupMode.INITIAL
&& startupOptions.getStartupMode() != StartupMode.TIMESTAMP
&& startupOptions.getStartupMode() != StartupMode.LATEST) { // <-- Add LATEST bypass here
throw new MongodbConnectorException(
ILLEGAL_ARGUMENT,
"Unsupported startup mode " + startupOptions.getStartupMode());
}
return this;
}
If you patch that in, plus the test regression Daniel asked for, this should be good to merge!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2][MongoDB-CDC] Support latest-offset startup mode without initial snapshot [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #11053:
URL: https://github.com/apache/seatunnel/pull/11053#issuecomment-4676247301
You’re welcome, and thanks for the quick follow-up here. From my side this is still in the same state as my last note: no new MongoDB-specific blocker on the current head, so I would just wait for maintainer merge timing. If the shared CI noise comes back again, feel free to ping and I can help check whether it looks like branch noise or a real regression.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2][MongoDB-CDC] Support latest-offset startup mode without initial snapshot [seatunnel]
Posted by "dheerusri324 (via GitHub)" <gi...@apache.org>.
dheerusri324 commented on PR #11053:
URL: https://github.com/apache/seatunnel/pull/11053#issuecomment-4676676088
Looks like the issue is almost resolved isn't it!😃
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2][MongoDB-CDC] Support latest-offset startup mode without initial snapshot [seatunnel]
Posted by "GabrielBBaldez (via GitHub)" <gi...@apache.org>.
GabrielBBaldez commented on PR #11053:
URL: https://github.com/apache/seatunnel/pull/11053#issuecomment-4675843357
Thanks for re-checking, Daniel! 🙏 I'll keep an eye out and ping if any shared-test noise shows up again.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2][MongoDB-CDC] Support latest-offset startup mode without initial snapshot [seatunnel]
Posted by "GabrielBBaldez (via GitHub)" <gi...@apache.org>.
GabrielBBaldez commented on PR #11053:
URL: https://github.com/apache/seatunnel/pull/11053#issuecomment-4671157236
Thanks @dheerusri324! I'll keep it open — looking forward to your review.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2][MongoDB-CDC] Support latest-offset startup mode without initial snapshot [seatunnel]
Posted by "GabrielBBaldez (via GitHub)" <gi...@apache.org>.
GabrielBBaldez commented on PR #11053:
URL: https://github.com/apache/seatunnel/pull/11053#issuecomment-4672907267
Quick CI status: the Build check is red, but the failures are outside the MongoDB module — `SqlServerCDCIT#testWithSchemaEvolution`, `SqlServerSchemaChangeIT#testMysqlCdcWithSchemaEvolutionCaseExactlyOnce` and `SeaTunnelEngineClusterRoleTest#testWorkerIsFirstMemberThenGetJobDetailStatus` (they run here because the PR touches the shared connector-cdc tree). No MongoDB test failed.
I've re-run the failed jobs. If these are known flaky on fork runners, any tip on getting a clean signal is appreciated 🙏
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2][MongoDB-CDC] Support latest-offset startup mode without initial snapshot [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #11053:
URL: https://github.com/apache/seatunnel/pull/11053#issuecomment-4675826713
@/tmp/pr11053_reply.md
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2][MongoDB-CDC] Support latest-offset startup mode without initial snapshot [seatunnel]
Posted by "GabrielBBaldez (via GitHub)" <gi...@apache.org>.
GabrielBBaldez commented on PR #11053:
URL: https://github.com/apache/seatunnel/pull/11053#issuecomment-4671554218
Haha perfect timing! 😄 Thanks for testing it locally and confirming the same root cause — great minds. The guard fix plus the regression tests on the real builder path are in (14baf90), so it should be ready for re-review. 🤝
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2][MongoDB-CDC] Support latest-offset startup mode without initial snapshot [seatunnel]
Posted by "GabrielBBaldez (via GitHub)" <gi...@apache.org>.
GabrielBBaldez commented on PR #11053:
URL: https://github.com/apache/seatunnel/pull/11053#issuecomment-4671305270
Thanks @DanielLeens — you're right, and that was the real gap: I had verified the generic `StartupConfig`/offset path but missed that `MongodbSourceConfigProvider.Builder#startupOptions` has its own runtime guard that still rejected `LATEST`, so the documented mode failed at source assembly. Fixed in the latest commit:
- **Issue 1:** the builder guard now accepts `LATEST` (alongside `INITIAL`/`TIMESTAMP`).
- **Issue 2:** added regression tests on the real builder path: `MongodbSourceConfigProvider.newBuilder()...startupOptions(StartupConfig(LATEST)).validate().create(0)` builds successfully and carries the mode through, and a negative test confirms unsupported modes (e.g. `EARLIEST`) are still rejected — so the guard can't silently drift again.
Module suite: 19/19 passing locally (JDK 11).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2][MongoDB-CDC] Support latest-offset startup mode without initial snapshot [seatunnel]
Posted by "chl-wxp (via GitHub)" <gi...@apache.org>.
chl-wxp merged PR #11053:
URL: https://github.com/apache/seatunnel/pull/11053
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2][MongoDB-CDC] Support latest-offset startup mode without initial snapshot [seatunnel]
Posted by "dheerusri324 (via GitHub)" <gi...@apache.org>.
dheerusri324 commented on PR #11053:
URL: https://github.com/apache/seatunnel/pull/11053#issuecomment-4670933738
Ah, great catch on ChangeStreamOffsetFactory already having the latest() implementation under the hood! Since you already have the tests and docs completely mapped out, definitely leave your PR open. I'll pull down your branch, test it locally, and drop a review. Nice work!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2][MongoDB-CDC] Support latest-offset startup mode without initial snapshot [seatunnel]
Posted by "GabrielBBaldez (via GitHub)" <gi...@apache.org>.
GabrielBBaldez commented on PR #11053:
URL: https://github.com/apache/seatunnel/pull/11053#issuecomment-4681133660
> This one honestly made my week — my first CDC contribution to SeaTunnel, merged. 🙏 Huge thanks to everyone who helped get it across the line.
>
> @DanielLeens, your reviews were the best part of this — walking the whole runtime chain and catching the builder-guard gap didn't just fix the PR, it taught me how the snapshot/consistency path actually works under the hood, and I came out understanding CDC a lot better than I went in. @dheerusri324, thank you for not just reviewing on paper but actually pulling the branch down and verifying the fix locally — and for the nudge to keep it open and see it through; that hands-on support genuinely made the difference. And @davidzollo, your welcome to the community really stuck with me — getting that kind of encouragement on a first contribution is exactly why people fall in love with open source.
>
> Excited to keep building on this one. 🚀
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org