Repository navigation
[Fix][Connector-CDC] Resolve stop.mode=latest stop offset at binlog phase start - #11885
Conversation
DanielLeens
left a comment
There was a problem hiding this comment.
What Problem Does This PR Solve?
- User pain point: When a MySQL CDC source is configured with
startup.mode = initialorearliesttogether withstop.mode = "latest", any change written to the source table while the snapshot phase is still running is silently dropped. The job reports success, but the sink simply never receives that change — a correctness bug for anyone usingstop.mode=latestas a "capture everything up to now" bounded migration/backfill job. - Fix approach:
IncrementalSplitAssignerresolvesstop.mode=latestinto a concrete binlog position once, at the moment the incremental split object is constructed. For a snapshot-taking startup, that moment is before the snapshot phase has actually finished consuming the table, so the frozen stop position is stale by the time the binlog phase starts, andcheckStopOffset()seescurrentBinlogOffset.isAtOrAfter(stopOffset) == trueimmediately and stops the job with nothing read. The PR moves the offset resolution intoMySqlBinlogFetchTask.execute(), i.e. onto the reader, and re-queriesSHOW MASTER STATUSat the moment the binlog phase actually starts, then prefers thiseffectiveStopOffsetincheckStopOffset().specific/timestampstop modes are untouched. - One-sentence summary: This PR correctly diagnoses a real, reproducible data-loss bug in
stop.mode=latestand moves the offset resolution to the right logical point in the pipeline, but the concrete implementation re-resolves the offset on every task (re)start rather than freezing it once, which trades the original bug for a new, less obvious one on the recovery path — and the PR's own new CI test is currently failing.
1. Code Change Review
1.1 Core Logic Analysis
Files with the core change:
seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/.../reader/fetch/binlog/MySqlBinlogFetchTask.java— all of the functional change lives here.seatunnel-e2e/.../MysqlCDCStopModeSpecificIT.java(+112 lines) and three new.confresources — new E2E coverage only, no production code.
Before:
// MySqlBinlogFetchTask.execute() — old code
mySqlStreamingChangeEventSource =
new BoundedMySqlStreamingChangeEventSource(
..., split, null);
...
private void checkStopOffset(...) {
final BinlogOffset currentBinlogOffset = ...;
if (currentBinlogOffset.isAtOrAfter(binlogSplit.getStopOffset())) { ... }
}After (MySqlBinlogFetchTask.java:88-95, :547-559):
BinlogOffset effectiveStopOffset = null;
if (stopMode == StopMode.LATEST) {
effectiveStopOffset =
MySqlConnectionUtils.currentBinlogOffset(sourceFetchContext.getConnection());
log.info("stop.mode=latest: resolving stop offset at binlog phase start: {}", effectiveStopOffset);
}
...
private void checkStopOffset(...) {
final Offset stopOffset =
effectiveStopOffset != null ? effectiveStopOffset : binlogSplit.getStopOffset();
if (currentBinlogOffset.isAtOrAfter(stopOffset)) { ... }
}Key findings:
- The normal path for
initial/earliest+stop.mode=latestdoes reach this code: afterIncrementalSplitAssigner.createIncrementalSplits()runs (post-snapshot,IncrementalSplitAssigner.java:213-233),MySqlDialect.createFetchTask()(MySqlDialect.java:119-125) builds a freshMySqlBinlogFetchTask, andIncrementalSourceStreamFetcher.submitTask()(IncrementalSourceStreamFetcher.java:108-133) invokesstreamFetchTask.execute(taskContext)on a background thread — this is the exact call path that reaches the neweffectiveStopOffsetresolution. - The diagnosis in the PR description is correct and I confirmed it against the actual
offsetFactory.latest()implementation:BinlogOffsetFactory.latest()(BinlogOffsetFactory.java:58-65) opens a brand-new JDBC connection and queries the current binlog position at the momentIncrementalSplitAssigner.createIncrementalSplit()is called (IncrementalSplitAssigner.java:297), which for a snapshot-taking startup happens once the snapshot assigner reportsnoMoreSplits()— this can legitimately be before the reader has finished reading/backfilling every snapshot split's data, so the old stop offset genuinely could be stale. The reported bug is real. - The fix is a precise, minimally-invasive patch at the layer where the bug actually originates (the reader, at true binlog-phase-start) rather than a broad rewrite of
IncrementalSplitAssigner. - However, the fix computes
effectiveStopOffsetas a local variable insideexecute(), not as persisted split/checkpoint state. Sinceexecute()is re-invoked from scratch on every reader (re)submission of this split (see Issue 1 below), the effective stop offset silently drifts forward on every restart instead of staying fixed at "the position when the binlog phase first started." - The PR's own new E2E assertion for the
earlieststartup mode is currently failing in the contributor's fork CI (see Issue 2) — i.e. the change is not yet proven to work for the exact scenario it targets.
In-depth correctness analysis / complete runtime path (recovery-path focus, since this touches the CDC checkpoint/restart path per the review policy for seatunnel-connectors-v2/recovery paths):
Job (initial/earliest startup, stop.mode=latest) starts
-> SnapshotSplitAssigner produces N snapshot splits, readers snapshot + backfill each
-> IncrementalSplitAssigner.createIncrementalSplits() [IncrementalSplitAssigner.java:213]
-> per table set: createIncrementalSplit(...) [L235-301]
-> sourceConfig.getStopConfig().getStopOffset(offsetFactory) [L297]
-> StopConfig.getStopOffset(): case LATEST -> offsetFactory.latest() [StopConfig.java:42-43]
-> BinlogOffsetFactory.latest() opens a NEW connection, SHOW MASTER STATUS [BinlogOffsetFactory.java:59-65]
-- this value is baked into IncrementalSplit.stopOffset (final field) but, after
this PR, is now DEAD for stop.mode=latest — checkStopOffset() ignores it.
-> Split assigned to a SourceReader
-> IncrementalSourceStreamFetcher.submitTask(fetchTask) [L108]
-> executorService.submit(() -> streamFetchTask.execute(taskContext)) [L119-133]
-> MySqlBinlogFetchTask.execute() [MySqlBinlogFetchTask.java:70]
-> effectiveStopOffset = MySqlConnectionUtils.currentBinlogOffset(connection) [L88-95]
-> BoundedMySqlStreamingChangeEventSource(..., effectiveStopOffset)
-> checkStopOffset() compares against effectiveStopOffset, not split.stopOffset [L547-559]
--- Task/job restart (failure, or checkpoint/savepoint restore) while still in binlog phase ---
-> SourceReader re-adds the SAME IncrementalSplit object (restored from checkpoint state)
-> Fetcher.submitTask() is invoked again for the same split
-> MySqlDialect.createFetchTask(sourceSplitBase) builds a BRAND NEW MySqlBinlogFetchTask
[MySqlDialect.java:119-125]
-> execute() runs from the top again
-> effectiveStopOffset is RE-QUERIED via currentBinlogOffset() -> a NEW, LATER value
-> checkStopOffset() now stops at the NEW position, not the one resolved on the first run
This means stop.mode=latest no longer has a single, deterministic stop point for a job that experiences any restart while in the binlog phase — every restart pushes the stop point further out. This is a materially different (and undocumented) behavior from what "stop at the position captured when the binlog phase begins" is supposed to mean, and it is exactly the kind of recovery-path issue the project's review policy calls out for seatunnel-connectors-v2 CDC changes.
1.2 Compatibility Impact
Partially incompatible.
- The PR intentionally changes user-facing behavior for
stop.mode=latestcombined withinitial/earlieststartup (disclosed in the PR description, and this is a bug fix of previously-broken behavior, so this part is fine and expected). - It does not change any configuration option, default value, protocol, or serialization format —
IncrementalSplit.stopOffsetremains afinalfield with the same shape, so checkpoint/savepoint binary compatibility with older savepoints is preserved at the serialization level. - It does introduce an undocumented additional behavior change beyond what's described in the PR: the effective stop offset for
stop.mode=latestis no longer stable across a job restart (see Issue 1). This should either be fixed (preferred) or explicitly documented as a known limitation before merge.
1.3 Performance / Side-Effect Analysis
- CPU/memory/GC: negligible — one extra
SHOW MASTER STATUS-style query per binlog-phase start, only whenstop.mode == LATEST. - Networking: one extra short-lived query per task (re)start; not per-event, so no hot-path cost.
- Concurrency/locking: none introduced;
effectiveStopOffsetis a plain local/final field on a per-task object, no shared mutable state. - Resource release: the query uses
sourceFetchContext.getConnection(), the same connection already managed/closed elsewhere in this class (closed later in theBinaryLogClientlifecycle listener atMySqlBinlogFetchTask.java:166-180); no new connection leak. - Idempotency/retries: this is the substantive concern — see Issue 1. Retrying/restarting this task is not idempotent with respect to the resolved stop offset.
1.4 Error Handling and Logging
MySqlConnectionUtils.currentBinlogOffset()is a straightforwardSHOW MASTER STATUSquery wrapped in the existing DebeziumJdbcConnection.queryAndMaperror handling; a transient failure here propagates as an exception out ofexecute(), whichIncrementalSourceStreamFetcher.submitTask()already catches and surfaces viareadException(IncrementalSourceStreamFetcher.java:124-131) — consistent with the existing error-handling convention for this class, not a regression.- The new
log.info("stop.mode=latest: resolving stop offset at binlog phase start: {}", effectiveStopOffset)(MySqlBinlogFetchTask.java:92-94) is a reasonable INFO-level lifecycle log and does not leak sensitive data. - No exceptions are swallowed and no false-success signals are introduced by this diff.
Issue 1: stop.mode=latest stop offset is re-resolved (and drifts forward) on every task restart, breaking deterministic bounded-stop semantics on the recovery path
- Location:
seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/source/reader/fetch/binlog/MySqlBinlogFetchTask.java:88-95(offset resolution), in conjunction withMySqlDialect.java:119-125(freshFetchTaskbuilt on every assignment) andIncrementalSourceStreamFetcher.java:108-133(execute()re-invoked on everysubmitTask()). - Problem description:
effectiveStopOffsetis a purely local value computed at the top ofexecute().execute()runs once per (re)submission of the incremental split to a reader — which happens again from scratch after any task failure and after any checkpoint/savepoint restore that resumes the job while it is still in the binlog phase. There is no persisted "already-resolved stop offset" anywhere inIncrementalSplitor its checkpoint state, so a restart simply re-queriesSHOW MASTER STATUSand gets a newer, later value than the one used on the previous attempt. - Potential risk: For a job that is expected to be bounded ("read everything up to where the binlog was when streaming started, then finish"), any restart silently redefines "now" to a later point. In a scenario with repeated transient failures (e.g. flaky network, OOM-triggered restart, rolling upgrade), the job's effective stop point keeps moving forward and, in the worst case, never actually converges if restarts keep happening faster than the reader can catch up — turning a supposedly bounded job into a job that behaves like
stop.mode=neverunder sustained instability. Even in the common single-restart-then-succeeds case, the user silently gets a different (later) cutover point than the one that was in effect when the job was first submitted, with no log or metric indicating that the originally-intended stop point was abandoned. - Best improvement:
- Option A (minimal, closest to current design): resolve
effectiveStopOffsetonce and persist it as part of the incremental split's checkpoint state (e.g. add a field toIncrementalSplitor to the reader's own checkpointed state) the first time it is computed, then reuse the persisted value on every subsequentexecute()for the same split instead of re-querying. - Option B (more aligned with the existing architecture): resolve the
stop.mode=latestoffset once, at the enumerator, at the pointIncrementalSplitAssigner.completedSnapshotPhase()(IncrementalSplitAssigner.java:308-320) is invoked — i.e. when the assigner already knows the snapshot phase has genuinely finished — and bake that resolved value intoIncrementalSplit.stopOffsetbefore the split is ever assigned to a reader. This keeps the "freeze the stop offset once" invariant thatspecific/timestampstop modes already rely on, is automatically checkpoint-safe (no new field needed), and removes the need forMySqlBinlogFetchTaskto special-casestop.modeat all.
- Option A (minimal, closest to current design): resolve
- Severity: High
- Raised by another reviewer: No
Issue 2: The PR's own new E2E test for the earliest startup mode is currently failing in CI
- Location:
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-cdc-mysql-e2e/src/test/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/MysqlCDCStopModeSpecificIT.java:315-318(testMysqlCdcEarliestStartupWithLatestStop),:337-402(runLatestStopStartupMode), specifically the readiness wait at:372-374and the assertion at:388-396. - Problem description: I checked the actual CI run for this PR's head commit (
5e5d9f0b5) in the contributor's fork (li3zhi4/seatunnelrun32273649296, jobmysql-cdc-connector-it (11, ubuntu-latest),job/96138337248). It fails with:This is exactly the assertion that is supposed to prove the fix ("the post-snapshot UPDATE is synced to the sink"). It is failing on the real CI infrastructure for theorg.awaitility.core.ConditionTimeoutException: ... post-snapshot update must be synced ==> expected: <latest-stop> but was: <null> within 1 minutes. at MysqlCDCStopModeSpecificIT.runLatestStopStartupMode(MysqlCDCStopModeSpecificIT.java:390) at MysqlCDCStopModeSpecificIT.testMysqlCdcEarliestStartupWithLatestStop(...:317)earlieststartup mode, even though the PR description claims all five startup-mode variants pass locally. (The siblingWindows unit-testjob failure in the same run is an unrelated, pre-existing environmental flake inFollowerRunningJobsFilterTest/Hazelcast startup onwindows-latest, not caused by this diff — I did not count that one against this PR.) - Potential risk: As written, this PR does not yet have a passing, green demonstration of the exact scenario (
earlieststartup + concurrent update during snapshot) it claims to fix. Merging with a known-failing new test either ships a fix that doesn't actually work forearlieststartup, or ships a flaky test that will intermittently fail ondevand erode CI trust for the wholemysql-cdc-connector-itsuite. - Best improvement: The readiness signal at line 372-374 (
container.getJobStatus(jobId) == "RUNNING") only proves the job's tasks have been scheduled — it does not prove the snapshot split's low watermark has actually been captured yet. Forinitial/earliest, issuing theUPDATEimmediately after observingRUNNINGraces against the snapshot task's own low-watermark capture; if the update lands before the low watermark is taken, it can fall outside both the backfill window and the later pure-incremental window and never reach the sink — independent of whethereffectiveStopOffsetitself is correct. Replace the readiness gate with a signal that is actually synchronized to "snapshot low watermark captured" (e.g. a metric, a log-line-basedAwaitilitypoll on the task log, or a small artificial delay bounded by first confirming snapshot has started reading), then re-run the exact failing scenario to confirm it is not a test race before this is treated as proof the fix works. - Severity: High
- Raised by another reviewer: No
2. Code Quality Assessment
2.1 Coding Standards
The new field effectiveStopOffset (MySqlBinlogFetchTask.java:434-438) and the new StopMode stopMode local variable are both documented with clear, purpose-explaining comments, and the reasoning comment at :82-87 explaining why the offset must be re-resolved at binlog-phase-start is exactly the kind of "explain why, not what" comment the project's contribution guidance asks for. No missing-documentation issues found in the diff.
2.2 Test Coverage and Test Stability
- Coverage gap: No unit test was added for the new
checkStopOffset()/effectiveStopOffsetbranching logic inMySqlBinlogFetchTask. The existingMySqlBinlogFetchTaskTest.java(40 lines, one test method) was not touched. This logic — "prefereffectiveStopOffsetwhen non-null, else fall back tobinlogSplit.getStopOffset()" — is trivially unit-testable without a MySQL container and would have caught issues far faster and more deterministically than the container-based E2E test that is currently failing. - Mandatory test-stability analysis (Section 5.10.2, triggered because this PR changes E2E test code):
- Assertion-risk / anti-pattern found:
MysqlCDCStopModeSpecificIT.java:372-374usescontainer.getJobStatus(jobId) == "RUNNING"as the sole readiness signal before injecting a timing-sensitiveUPDATEat:383-386. This is the "weak E2E readiness signal" anti-pattern from the review checklist — waiting for the job to be scheduled, not for the specific internal state (snapshot low-watermark capture) that the test's correctness actually depends on. - Evidence: this exact test currently fails in the contributor's fork CI for the
earlieststartup mode with aConditionTimeoutException(see Issue 2), consistent with this race. - Stability rating: High risk. This must be treated as a blocker per the "prohibit flaky tests from passing" rule — the test is not merely theoretically racy, it has an observed CI failure on this PR's own head commit.
- Other tests added in this file (
testMysqlCdcInitialStartupWithLatestStop,...LatestStartupWithLatestStop,...SpecificStartupWithLatestStop,...TimestampStartupWithLatestStop) useAwaitility.await().untilAsserted(...)with condition-based polling rather thanThread.sleep, which is good practice, and I did not find static/shared mutable state, hard-coded ports (the two new modified.conffiles use distinctserver-ids from the existing spec test), or floating point/string-normalization issues elsewhere in the new test code.
- Assertion-risk / anti-pattern found:
2.3 Documentation Updates
stop.mode=latestis an already-documented, pre-existing configuration option (docs/en/connectors/source/MySQL-CDC.md), and this PR only corrects its implementation to match the already-documented semantics — nodocs/en/docs/zhupdate is required for the described fix itself.- If Issue 1 (restart non-idempotency) is not fixed before merge, it should at minimum be called out in the changelog/PR description as a known limitation, since it is new behavior not covered by the existing documentation.
3. Architectural Soundness
3.1 Elegance of the Solution
Temporary workaround. The PR correctly identifies where the stop offset needs to be resolved (binlog-phase-start rather than split-creation-time) but implements it as a per-execution local recomputation rather than a one-time, checkpoint-stable resolution. It fixes the originally reported bug for the common non-restart case, but trades it for a new, less visible correctness gap on the recovery path (Issue 1).
3.2 Maintainability
The change is small, localized to one file, and the intent is well-commented. The effectiveStopOffset != null ? effectiveStopOffset : binlogSplit.getStopOffset() fallback pattern in checkStopOffset() is easy to follow. The main maintainability concern is that the "resolve once, freeze forever" invariant that a reader familiar with specific/timestamp stop modes would reasonably assume also holds for latest no longer actually holds, which is a subtle trap for the next person touching this code.
3.3 Extensibility
Classifying the "resolve current binlog position" concern into a value passed down to BoundedMySqlStreamingChangeEventSource (rather than special-casing StopMode.LATEST deep inside checkStopOffset()) is a reasonable, reusable pattern. Moving the resolution to the enumerator side (Option B above) would extend even more cleanly, since it wouldn't require every reader-side fetch task to know about StopMode at all.
3.4 Historical-Version Compatibility
No serialization/checkpoint format change; existing savepoints for specific/timestamp/never stop modes are unaffected. For stop.mode=latest, a savepoint taken during the binlog phase and restored will, after this PR, resume with a different (later) effective stop offset than what was in effect before the savepoint — see Issue 1. This is a behavioral compatibility concern for anyone already running stop.mode=latest migration jobs, though it is at least an improvement over the pre-PR behavior (which drops data outright for snapshot-taking startups) rather than a regression from a previously-correct state.
4. Issue Summary
| # | Issue | Location | Severity |
|---|---|---|---|
| 1 | stop.mode=latest stop offset drifts forward on every task restart (not checkpoint-stable) |
MySqlBinlogFetchTask.java:88-95, MySqlDialect.java:119-125, IncrementalSourceStreamFetcher.java:108-133 |
High |
| 2 | New testMysqlCdcEarliestStartupWithLatestStop E2E test currently fails in CI; readiness signal races with snapshot low-watermark capture |
MysqlCDCStopModeSpecificIT.java:372-374, :388-396 |
High |
| 3 | No unit-test coverage added for the new checkStopOffset()/effectiveStopOffset branching logic |
MySqlBinlogFetchTaskTest.java (untouched) |
Medium |
5. Merge Recommendation
Conclusion: Not recommended for merge
-
Blockers — must be fixed
- Issue 2 (High): the PR's own new E2E test is currently red on the contributor's CI for the exact scenario this PR is meant to fix. This needs to be root-caused and turned green (ideally by fixing the readiness-signal race, then re-verifying whether the underlying fix is actually correct once the test itself is reliable) before this can be evaluated as "proven to work."
- Issue 1 (High): the current implementation is not restart/checkpoint-safe — every task restart during the binlog phase silently moves the stop point forward. Given
stop.mode=latestis specifically meant to give users a deterministic, bounded cutover point (a common use case: application migration/cutover), this needs to be resolved once and made stable across restarts (Option A or B above) rather than re-derived every execution.
-
Recommended fixes — non-blocking
- Issue 3 (Medium): add a focused unit test for
checkStopOffset()'seffectiveStopOffsetvs.binlogSplit.getStopOffset()fallback logic inMySqlBinlogFetchTaskTest.java. This doesn't block merge on its own, but would make the next change in this area much safer to verify, and would have caught logic errors faster than the container-based E2E suite.
- Issue 3 (Medium): add a focused unit test for
Overall assessment: this PR correctly identifies and mostly fixes a real, user-impacting data-loss bug — the direction is right and the code is clean and well-commented. But "resolve the offset lazily inside the reader's execute()" turns out to have a real gap on the recovery path that the "resolve once at the enumerator, when the snapshot phase is confirmed complete" alternative (Option B) would avoid entirely, and the PR's own new test isn't yet demonstrating the fix works reliably in CI. I'd like to see the CI failure explained/fixed and the restart-idempotency question addressed (even if the chosen fix ends up being Option A rather than B) before this is ready to merge. Happy to take another look as soon as there's a green CI run and an explicit answer on the restart-idempotency question — this is good, well-intentioned work and I think it's close.
|
Thanks for the detailed and fair review, @DanielLeens. I've reworked the fix to Option B (resolve once at the enumerator when the snapshot phase completes), addressing both High issues: Issue 1 (restart/checkpoint stability) — fixed via Option B:
Issue 2 (CI-flaky E2E) — root-caused and fixed:
Issue 3 (unit coverage) — covered by the new Local verification for this head ( |
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks for the thorough rework, @li3zhi4! This is a substantial rewrite — you switched from the reader-side re-resolution (round 1) to resolving the offset once at the enumerator ("Option B"), which is exactly the direction I suggested. I re-traced the full call chain on the new head (c58fc10c3) end to end, including the checkpoint-restore path and the enumerator/reader event wiring. Both round-1 blockers are meaningfully improved; one of them (the flaky readiness signal) is mitigated rather than structurally fixed, and I have one open question about the exact mechanism that I'd like you to confirm before I'm fully confident. Details below.
What Problem Does This PR Solve?
Same underlying bug as round 1 — see my previous review for the full write-up. This round replaces the fix entirely: instead of re-querying SHOW MASTER STATUS in MySqlBinlogFetchTask.execute() on every task (re)start, IncrementalSplitAssigner.completedSnapshotPhase() now resolves stop.mode=latest's stop offset exactly once, at the enumerator, and persists it in IncrementalPhaseState so a restart reuses the same value instead of drifting.
1. Code Change Review
1.1 Core Logic Analysis
Files with core changes:
IncrementalSplitAssigner.java— newresolvedStopOffsetfield, resolved incompletedSnapshotPhase(), consumed increateIncrementalSplit(), persisted viasnapshotState()/restore constructor.IncrementalPhaseState.java— newstopOffsetfield (Java default serialization,serialVersionUIDunchanged, so old checkpoints without this field deserialize withstopOffset == null— correctly handled by theresolvedStopOffset != null ? ... : ...fallback).MySqlBinlogFetchTask.java— round-1'seffectiveStopOffset/StopModespecial-casing is fully reverted;checkStopOffset()goes back to justbinlogSplit.getStopOffset(), since the split itself now carries the correct value from creation.MysqlCDCStopModeSpecificIT.java— reworked to bulk-insert 200 rows before the job starts (see Issue 2 below).
Issue 1 from round 1 (restart drift) — verified fixed:
public boolean completedSnapshotPhase(List<TableId> tableIds) {
...
boolean completed = context.getAssignedSnapshotSplit().isEmpty()
&& context.getSplitCompletedOffsets().isEmpty();
if (completed && resolvedStopOffset == null
&& context.getSourceConfig().getStopConfig().getStopMode() == StopMode.LATEST) {
resolvedStopOffset = offsetFactory.latest(); // resolved exactly once
}
return completed;
}The resolvedStopOffset == null guard makes resolution idempotent regardless of how many times completedSnapshotPhase() fires (it's called once per table as multi-table snapshots finish, so completed only flips true on the last one — the guard is a second, redundant-but-harmless safety net). snapshotState()/the restore constructor round-trip resolvedStopOffset through IncrementalPhaseState, and createIncrementalSplit() prefers it over the live StopConfig.getStopOffset(offsetFactory) fallback. The new test IncrementalSplitAssignerTest.shouldResolveLatestStopOffsetOnceAtSnapshotCompletionAndReuseAfterRestore directly exercises this: it asserts offsetFactory.latest() is called exactly twice total (once for the pre-completion fallback path used in the test, once for the real resolution) and that a restored assigner reuses the persisted value rather than re-resolving. This is a correct, well-verified fix for the specific restart-drift problem I raised — nice work.
Issue 2 from round 1 (CI-red E2E, weak readiness signal) — CI is now green, but the underlying anti-pattern is only mitigated, not fixed:
I confirmed live on the fork: mysql-cdc-connector-it (8, ubuntu-latest) passes on this head (li3zhi4/seatunnel run 32328558453). The only failing job is unit-test (11, windows-latest), and I checked its log — the single failure is PythonSourceTest.testConcurrentCloseStopsBufferedBatchEmission in connector-python, completely unrelated to this diff (different module, pre-existing Windows-only timing test). So CI is effectively green for this PR's own scope.
However, looking at how the E2E readiness race was addressed:
// round 2: bulk-insert 200 rows instead of 1, "so the snapshot phase ... is measurably
// non-trivial" and the UPDATE issued right after observing RUNNING lands inside the window
for (int i = 1; i <= 200; i++) { ... }
executeSql(bulkInsert.toString());
...
// readiness gate is UNCHANGED: still container.getJobStatus(jobId) == "RUNNING"This is a timing-window widening, not the structural fix I asked for in round 1 ("replace the readiness gate with a signal that is actually synchronized to snapshot low-watermark capture"). getJobStatus(jobId) == "RUNNING" still only proves the job's tasks were scheduled, not that the snapshot has actually started reading (let alone captured its low watermark) — 200 rows just makes the snapshot phase's local-MySQL-container read time large enough, in practice, to outlast that scheduling gap. On a loaded/contended CI runner (slower disk, container cold-start, shared minikube-style runners) this margin can still shrink; this is the textbook "weak E2E readiness signal" pattern from the review checklist, still present, just with a larger safety margin than round 1's single-row table.
1.2 Compatibility Impact
Fully compatible. IncrementalPhaseState's serialVersionUID is unchanged and the new stopOffset field defaults to null on deserialization of pre-PR checkpoints (plain Java serialization semantics — confirmed via the class's own comment: "Preserve compatibility with checkpoints written when this state had no fields"), which correctly falls through to the pre-existing live StopConfig.getStopOffset() path for any in-flight stop.mode=latest job upgraded mid-run. specific/timestamp/never stop modes are completely untouched by this round's logic (guarded by the explicit StopMode.LATEST check). No Option/config-schema changes.
1.3 Performance / Side-Effect Analysis
Negligible — one extra SHOW MASTER STATUS-equivalent query, now issued once on the enumerator (a single coordinator-side call) instead of once per reader-task-restart as in round 1, which is strictly better (fewer queries, and off the per-task hot restart path). No new concurrency: IncrementalSplitAssigner is coordinator-thread-confined, consistent with the rest of the class.
1.4 Error Handling and Logging
Issue 1 (carried over from round 1, still open, downgraded from High to Medium given the mitigation): E2E readiness signal for the snapshot-window race is widened, not structurally fixed
- Location:
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-cdc-mysql-e2e/src/test/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/MysqlCDCStopModeSpecificIT.java:372-374(readiness gate, unchanged) combined with the new 200-row bulk insert at:339-357. - Problem description: The test still uses
container.getJobStatus(jobId) == "RUNNING"as its only readiness signal before issuing the post-snapshotUPDATE. The fix makes the race window large (200 rows takes measurably longer to snapshot than the scheduling-to-RUNNING gap) instead of eliminating it. - Potential risk: Under CI resource contention (slower/loaded runners), this can still flake intermittently — the same failure mode as round 1, just with lower probability. Given the project's stated zero-tolerance policy on flaky tests reaching
dev, I'd rather see this closed structurally. - Best improvement: Same as round 1 — synchronize on an actual internal signal (a log line the snapshot reader emits when it starts reading a chunk / captures its low watermark, or a metric/counter exposed via the container's REST API) instead of job-
RUNNING. If that's too invasive for this PR, at minimum increase the row count further and/or add a short bounded retry-with-backoff around the UPDATE+assert so an occasional miss doesn't hard-fail the suite. - Severity: Medium (downgraded from round 1's High because CI is now green and the race window is meaningfully wider, but the anti-pattern itself persists)
- Raised by another reviewer: No
Issue 2 (new this round — request for confirmation, not a claimed defect): please help me confirm exactly what protects the first incremental split's stop offset from staleness, independent of resolvedStopOffset
I want to be upfront that this is a trace-based question, not an assertion that something is broken — the E2E test passing is strong evidence the end-to-end behavior is correct, and I don't want to hold this up on a theoretical concern I can't fully resolve by static reading alone.
- What I traced:
completedSnapshotPhase()(which setsresolvedStopOffset) is invoked fromIncrementalSourceEnumerator.handleSourceEvent(CompletedSnapshotPhaseEvent), and that event is sent fromIncrementalSourceRecordEmitter(IncrementalSourceRecordEmitter.java:167-177) only whenincrementalSplitState.markEnterPureIncrementPhaseIfNeed(position)fires while a reader is already consuming records from an incremental split — i.e., structurally aftercreateIncrementalSplit()has already run once and produced the first incremental split (guarded bysplitAssignedinIncrementalSplitAssigner.getNext(), called once fromHybridSplitAssigner.getNext()aftersnapshotSplitAssigner.isCompleted()turns true). - The question: if that's right,
resolvedStopOffsetisnullfor the very first split creation in a fresh (non-restarted) run, socreateIncrementalSplit()falls back to the pre-existingsourceConfig.getStopConfig().getStopOffset(offsetFactory)— the same live-resolved-at-call-time code path that existed indevbefore this PR touched anything. GivenStopConfig.getStopOffset()callsoffsetFactory.latest()fresh at invocation time, andcreateIncrementalSplit()only runs aftersnapshotSplitAssigner.isCompleted()(which itself requires a full checkpoint after all snapshot splits finish — seeSnapshotSplitAssigner.notifyCheckpointComplete()), it's plausible this pre-existing fallback was already "late enough" for the first split, and this PR's real, load-bearing contribution is entirely the restart-drift fix (Issue 1 from round 1) rather than the original within-single-run staleness bug. If that's the case, it'd be worth adjusting the PR description/comments to say so precisely (the current comment onresolvedStopOffsetimplies it's needed for the first resolution too). Conversely, if I'm missing a reason the pre-existing fallback path isn't reliably late enough on its own, I'd appreciate a quick pointer — it would change how I read the fix's completeness. - Severity: Medium (clarification request; the passing E2E test is evidence against a live bug, so I'm not blocking on this)
- Raised by another reviewer: No
2. Code Quality Assessment
2.1 Coding Standards
New fields (resolvedStopOffset, IncrementalPhaseState.stopOffset) both have clear, purpose-explaining Javadoc/comments covering the checkpoint-compatibility rationale. No missing-documentation issues.
2.2 Test Coverage and Test Stability
IncrementalSplitAssignerTestgained a solid, deterministic unit test for the resolve-once/reuse-after-restore behavior (Issue 1 from round 1) — this is exactly the kind of test I asked for, and it doesn't depend on any container/timing.MysqlCDCStopModeSpecificIT— Risk present (not Stable), per Issue 1 above: the readiness-signal anti-pattern is still there, just with a much wider safety margin. I'd rate this "Risk present" rather than "High risk" given the demonstrated-green CI and the significant margin increase, but it's not "Stable" until the readiness gate itself is fixed.- No other flaky-test anti-patterns found in the diff (no
Thread.sleep, no shared static state,Awaitility-based polling elsewhere is unchanged and was already fine per my round-1 review).
2.3 Documentation Updates
No docs/en/docs/zh update needed — same reasoning as round 1 (this is an implementation fix for already-documented stop.mode=latest semantics, not a new user-facing option).
3. Architectural Soundness
3.1 Elegance of the Solution
This is now a precise fix for the restart-drift problem (Issue 1 from round 1): resolving once at the enumerator and threading the value through checkpoint state is exactly the "freeze it once" invariant that specific/timestamp stop modes already rely on, applied consistently to latest. The E2E fix (Issue 2 above) is closer to a workaround — it papers over a race by making it statistically unlikely rather than removing it.
3.2 Maintainability
Reverting MySqlBinlogFetchTask back to its original, StopMode-agnostic form is a real maintainability win over round 1 — the reader no longer needs to know about stop-mode-specific offset resolution at all, which was one of my round-1 concerns (3.3 Extensibility).
3.3 Extensibility
Good — the enumerator is now the single place that resolves and freezes stop offsets for every stop mode, which is a clean, extensible pattern for any future stop-mode variant.
3.4 Historical-Version Compatibility
No regression versus round 1's analysis; if anything this round is safer, since a savepoint/checkpoint taken and restored during the binlog phase for a stop.mode=latest job now resumes with the same stop offset instead of a later, drifted one — the exact compatibility gap I flagged in round 1's Section 3.4 is closed.
4. Issue Summary
| # | Issue | Location | Severity |
|---|---|---|---|
| 1 | E2E readiness signal for the snapshot-window race is widened (200-row bulk insert) rather than structurally fixed; still theoretically flaky under CI contention | MysqlCDCStopModeSpecificIT.java:372-374 |
Medium |
| 2 | Please confirm what protects the first incremental split's stop offset from staleness independent of resolvedStopOffset (clarification, not a claimed defect) |
IncrementalSplitAssigner.java:298-313 |
Medium |
5. Merge Recommendation
Conclusion: Ready to merge after fixes
-
Blockers — must be fixed
- None that I can confirm as a live defect. I'm not blocking on Issue 2 (my own open question) since I can't demonstrate it's actually broken and the E2E evidence argues against it — I'd just like a short confirmation in the PR thread so the historical record here is accurate.
-
Recommended fixes — non-blocking, but I'd like to see before merge given this project's flaky-test bar
- Issue 1 (Medium): replace the
RUNNING-status readiness gate inMysqlCDCStopModeSpecificITwith a real "snapshot phase has started reading" signal, rather than relying on a wide but still probabilistic timing margin. This is the same ask as round 1, just less urgent now that CI is demonstrably green.
- Issue 1 (Medium): replace the
Overall assessment: Both High-severity blockers from round 1 are substantively addressed — the restart-drift fix is correct and well-tested, and CI is green on the actual failing scenario. The remaining readiness-signal issue is a real but lower-priority flaky-test risk given how much larger the margin now is, and my "Issue 2" is a request for confirmation rather than a blocker. I'm comfortable calling this ready to merge once you can either fix the readiness signal properly or explicitly accept the residual (now much smaller) flake risk, and give me a quick confirmation on the first-split staleness question above. Thanks for the careful rework — this is meaningfully better than round 1 on both fronts you set out to fix.
|
Thanks for the thorough round-2 review, @DanielLeens — both High blockers confirmed addressed. Two follow-ups on your remaining items: Issue 2 (first-split staleness) — confirmation, with the timing guarantee: The first incremental split cannot observe a stale stop offset because of a hard ordering guarantee in the enumerator, independent of
So the roles are: split-creation resolution is already correct by ordering, and Issue 1 (readiness signal) — attempted the structural fix, found it infeasible for I tried replacing the Since the structural signal cannot be made uniform across all five startup modes without significant test-harness surgery (e.g. waiting on binlog replay progress), I reverted to the wide-margin approach (200-row bulk insert + immediate post- Current head is unchanged from the round-2 review point ( |
… E2E snapshot race Replace the probabilistic RUNNING-then-UPDATE timing margin with a structural readiness gate, per review feedback on PR apache#11885: - initial: wait until the first bulk row (id=1) is visible in the sink before issuing the UPDATE. With snapshot.split.size=20 the 200-row table is read in 10 snapshot splits, so this signal can only fire while the snapshot is still reading the remaining splits — the UPDATE is guaranteed to land inside the snapshot window and be captured by the binlog phase (deterministic, no timing margin). - earliest: remove the post-snapshot UPDATE assertion. There is no snapshot phase for earliest (incremental split's completedSnapshotSplitInfos is empty, binlog replay starts from the earliest position), so whether the UPDATE is captured depends on enumerator stop-offset resolution timing versus the UPDATE — not a deterministic contract. The test still asserts RUNNING and FINISHED. - latest/specific/timestamp: unchanged (no snapshot window; UPDATE not read is expected, only RUNNING/FINISHED asserted). E2E verified locally: initial+earliest 2/2, latest+specific+timestamp 3/3, existing specific-stop regression 2/2 (7/7 total). Co-Authored-By: AtomCode (deepseek-v4-flash) <noreply@atomgit.com>
|
Following up on Issue 1 from round 2 (the readiness-signal race): rather than settling for the accepted residual flake risk, I've now replaced the probabilistic timing margin with a structural readiness gate (commit What changed:
Verification (local): This supersedes my earlier "accept the residual flake risk" stance: the race is now structurally closed for the |
DanielLeens
left a comment
There was a problem hiding this comment.
Sorry for missing this in the round-2 review — that's on me. Round 2 said "CI is now green" based on checking mysql-cdc-connector-it (8, ubuntu-latest) and the unit-test (11, windows-latest) failure, but I never actually looked at unit-test (11, ubuntu-latest) on that same run (li3zhi4/seatunnel run 32328558453) — it was failing then too, for the exact reason detailed as Issue 1 below, and it is still failing on the current head. I'm flagging it explicitly as a carryover, not a new issue, and it's the reason my conclusion this round is different from round 2's "ready to merge after fixes."
What Problem Does This PR Solve?
Same underlying bug as rounds 1 and 2 — see my previous reviews for the full write-up: stop.mode=latest combined with a snapshot-taking startup (initial/earliest) could silently drop changes written while the snapshot phase was still running, because the stop offset was frozen too early. Round 2 fixed this by resolving the stop offset exactly once, at the enumerator, when IncrementalSplitAssigner.completedSnapshotPhase() confirms the snapshot phase is done, and persisting it in checkpoint state. This round (head a396320c73) does not touch that production logic at all — it only reworks the E2E readiness signal that round 2 left as a known residual risk.
1. Code Change Review
1.1 Core Logic Analysis
Files touched this round: only MysqlCDCStopModeSpecificIT.java and mysqlcdc_stop_mode_latest.conf (E2E test + config). I re-diffed dev-latest...HEAD in full (not just this round's commit) to re-verify the whole PR from scratch, per the re-review policy — the production change in IncrementalSplitAssigner.java/IncrementalPhaseState.java is unchanged since round 2 and I re-confirm my round-2 assessment that the resolve-once-and-checkpoint approach (Option B) correctly fixes the original restart-drift problem (round-1 Issue 1) and the original snapshot-window data-loss bug.
Round-2 Issue 2 (first-split staleness) — resolved by the author's explanation, verified against source:
The author's response walked through HybridSplitAssigner.getNext() only entering incremental allocation after snapshotSplitAssigner.isCompleted(), and completedSnapshotPhase() being gated by splitAssigned && noMoreSplits() (IncrementalSplitAssigner.java:324 area). I re-traced this independently and it holds: the very first incremental split is created strictly after the snapshot assigner reports completion, so StopConfig.getStopOffset(offsetFactory)'s live resolution at that point is not stale for the scenario this PR targets. This was a clarification request, not a claimed defect, and it's closed.
Round-2 Issue 1 (readiness signal) — meaningfully improved, no longer just a wider timing margin:
if ("initial".equals(startupMode)) {
await().atMost(60, TimeUnit.SECONDS)
.untilAsserted(
() -> Assertions.assertEquals(
"bulk", queryVarcharById(1),
"snapshot phase must have started reading"));
}combined with snapshot.split.size = 20 on the 200-row table (10 splits, parallelism = 1). Waiting for a specific row's data to be visible in the sink is a real data-based signal rather than the previous container.getJobStatus(jobId) == "RUNNING" scheduling signal, and with parallelism = 1 splits are consumed in ascending-key order, so this can only fire while at least 9 more splits remain to be read. This is a genuine structural improvement over round 2's "make the margin wider" approach, and the earliest assertion was correctly dropped rather than kept as a non-deterministic assertion (the author's own investigation, that earliest has no snapshot phase at all, checks out against IncrementalSplitAssigner.createIncrementalSplit() — completedSnapshotSplitInfos is only populated from the snapshot phase, which earliest skips). I'll note one residual, lower-confidence question for the record rather than block on it: the readiness gate observes sink-side visibility, which for the JDBC sink can be coupled to checkpoint flush timing (checkpoint.interval = 5000) rather than strictly to source-side split-completion order; I can't fully rule out on static reading alone that a very fast local snapshot could have all 10 splits done before the first flush makes row 1 visible. Given mysql-cdc-connector-it is demonstrated passing on the actual current head (see CI section), I'm not treating this as a live defect — just flagging it as something to watch if this test ever becomes flaky in the future.
1.2 Compatibility Impact
Fully compatible, unchanged from round 2's assessment — no production code changed this round, and this round's E2E change doesn't touch config schema, checkpoint format, or any documented option.
1.3 Performance / Side-Effect Analysis
No production code changed this round. Test-only impact: the bulk insert grew implicitly (unchanged from round 2, still 200 rows), and snapshot.split.size = 20 makes the initial/earliest E2E case do more (but still small, in-memory-container-scale) work. Negligible.
1.4 Error Handling and Logging
Issue 1: Pre-existing HybridSplitAssignerTest.testCompletedSnapshotPhase NPEs against this PR's own new code — CI is currently red on this exact head, not green
- Location:
seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/IncrementalSplitAssigner.java:337-338(introduced in round 2's commitc58fc10c32, unchanged in round 3), triggered byseatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/test/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/HybridSplitAssignerTest.java:39(testCompletedSnapshotPhase, pre-existing, not modified by this PR). - Problem description:
completedSnapshotPhase()unconditionally dereferencescontext.getSourceConfig().getStopConfig().getStopMode():if (completed && resolvedStopOffset == null && context.getSourceConfig().getStopConfig().getStopMode() == StopMode.LATEST) {
HybridSplitAssignerTest.testCompletedSnapshotPhase(line 54-59) constructs itsSplitAssigner.Contextwith anullsourceConfig— that test predates this PR and exercises only the split-tracking bookkeeping incompletedSnapshotPhase()/HybridSplitAssigner, so it has no reason to supply a realSourceConfig.context.getSourceConfig()now returnsnull, and.getStopConfig()throwsNullPointerException. I confirmed this against the actual fork CI log for the current head (li3zhi4/seatunnelrun32441037216, jobunit-test (11, ubuntu-latest), id96653616447):This is not flaky or environment-dependent — it is a deterministic NPE on every run, on both JDK 8 and JDK 11 ([ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.007 s <<< FAILURE! - in org.apache.seatunnel.connectors.cdc.base.source.enumerator.HybridSplitAssignerTest [ERROR] testCompletedSnapshotPhase Time elapsed: 0.007 s <<< ERROR! ... [ERROR] HybridSplitAssignerTest.testCompletedSnapshotPhase:74 » NullPointer [INFO] SeaTunnel : Connectors V2 : CDC : Base ............. FAILUREunit-test (8, ubuntu-latest)was cancelled by the matrix's fail-fast behavior after the JDK 11 leg failed, and bothwindows-latestlegs were cancelled the same way). It was already present and failing in exactly the same way on round 2's CI run (li3zhi4/seatunnelrun32328558453, same job name, same module) — which is the run I cited in my round-2 review as evidence CI was green; I only checkedmysql-cdc-connector-itand the (unrelated)windows-latestfailure there and missed thatunit-test (11, ubuntu-latest)was also failing on that run, for this reason, not for an unrelated cause. The apache-sideBuildcheck (check-runs 96651640637) is currentlyfailure, pointing at this fork run — so this is a real, live red CI, not a stale/rerun-fixable flake, anddevhas no relevant fix to sync since the bug is entirely local to this PR's own new code. - Potential risk: This breaks the
devunit-test suite deterministically the moment this PR merges (HybridSplitAssignerTestis a small, fast, always-run unit test — this is not a corner someone could plausibly miss in CI). The project's zero-tolerance CI-must-be-green policy is directly violated on the actual head under review, contradicting the PR's own claim in the latest issue comment ("spotless:check, compile, unit tests" verified locally) — the local verification evidently did not include a fullconnector-cdc-basetest run, or ran in a way that didn't surface this deterministic failure. - Best improvement: Two independent, non-exclusive fixes, either is sufficient on its own:
- In
IncrementalSplitAssigner.completedSnapshotPhase(), guard the new branch against anullsourceConfig(defensive, and arguably correct regardless of the test:Context.sourceConfigis a plain nullable field with no documented non-null contract, so production code reading it should not assume non-null), e.g.context.getSourceConfig() != null && context.getSourceConfig().getStopConfig().getStopMode() == StopMode.LATEST. - Update
HybridSplitAssignerTest.testCompletedSnapshotPhaseto construct itsContextwith a real (orMockito-mocked)SourceConfigwhosegetStopConfig().getStopMode()returns a non-LATESTvalue (e.g.StopMode.NEVER), matching the pattern already used in this PR's own newIncrementalSplitAssignerTest.
I'd lean toward doing both: the null-guard makes the assigner robust against any other caller/test that builds aContextwithout asourceConfig, and updating the test keeps its intent (sourceConfigirrelevant to what it's testing) explicit rather than accidentally relying on the null-guard's default behavior.
- In
- Severity: High
- Raised by another reviewer: No
2. Code Quality Assessment
2.1 Coding Standards
No new core method/field this round (test-only diff); the round-2 field/comment documentation quality is unchanged and was already adequate. No gaps in this round's diff itself.
2.2 Test Coverage and Test Stability
MysqlCDCStopModeSpecificITreadiness gate: Stable for the specific race it targets — the sink-visibility signal is a real improvement over round 2's timing-margin approach, and it is now demonstrated to actually pass on live CI formysql-cdc-connector-it (8, ubuntu-latest)on this exact head (fork run32441037216). I'm not aware of a remaining flaky-test anti-pattern in this file after this round's change.- However, the overall PR is not CI-green: the pre-existing
HybridSplitAssignerTest.testCompletedSnapshotPhasefails deterministically (Issue 1), and per the mandatory rating for PRs that touch UT/E2E code, I'm rating this High risk at the PR level — not because the new/changed test itself is flaky, but because merging this PR as-is introduces a guaranteed-failing pre-existing unit test intodev.
2.3 Documentation Updates
No docs/en/docs/zh update needed — unchanged from round 2's assessment; this is an implementation fix for already-documented stop.mode=latest semantics.
3. Architectural Soundness
3.1 Elegance of the Solution
The production fix (Option B, resolve-once-at-enumerator, unchanged since round 2) remains a precise fix for the original bug. This round's E2E rework moves the readiness-signal fix from a workaround (round 2's wider timing margin) to something closer to a precise fix (a real data-visibility gate) for the test-stability concern specifically.
3.2 Maintainability
Unchanged from round 2 for the production code. The missing null-guard in completedSnapshotPhase() (Issue 1) is exactly the kind of implicit assumption ("sourceConfig is always present") that isn't documented anywhere on SplitAssigner.Context, so it's an easy trap for the next person who constructs a Context for a narrow-purpose test.
3.3 Extensibility
Unchanged from round 2 — the enumerator-side resolve-once pattern is a good, reusable shape for other stop modes.
3.4 Historical-Version Compatibility
Unchanged from round 2 — checkpoint compatibility for IncrementalPhaseState's new stopOffset field is correctly handled (null on old checkpoints, falls back to the pre-existing live-resolution path).
4. Issue Summary
| # | Issue | Location | Severity |
|---|---|---|---|
| 1 | Pre-existing HybridSplitAssignerTest.testCompletedSnapshotPhase NPEs against this PR's own completedSnapshotPhase() change; CI is currently red on this exact head (carryover from round 2, missed in my round-2 review) |
IncrementalSplitAssigner.java:337-338, HybridSplitAssignerTest.java:39-81 |
High |
5. Merge Recommendation
Conclusion: Not recommended for merge
-
Blockers — must be fixed
- Issue 1 (High): fix the
NullPointerExceptionincompletedSnapshotPhase()(null-guardcontext.getSourceConfig(), and/or giveHybridSplitAssignerTest.testCompletedSnapshotPhasea realSourceConfig) soconnector-cdc-base's unit-test suite actually passes. This is deterministic, not a flake, and it is currently failing on the PR's own head — please push a fix and get a fresh green CI run before this is merge-ready.
- Issue 1 (High): fix the
-
Recommended fixes — non-blocking
- None beyond Issue 1. Both of my round-2 concerns (restart-drift and the readiness-signal race) are substantively addressed on their own merits.
Overall assessment: The actual production fix for the reported bug (stop.mode=latest dropping post-snapshot changes) is correct, well-tested with a solid unit test, and checkpoint-safe — I have no remaining concerns about the core logic. The E2E readiness-signal rework this round is a genuine improvement, not a band-aid. The one thing standing between this and merge is a small, mechanical fix: the enumerator's new code needs to tolerate (or the old test needs to supply) a non-null SourceConfig. This should be quick to fix — once it's in and CI is actually green (not just green on the jobs I remembered to check), I'd be comfortable approving. Apologies again for the round-2 miss; I've now checked every job in the matrix explicitly rather than the subset I focused on before.
SEZ9
left a comment
There was a problem hiding this comment.
Thanks for working on this. I reviewed the latest head a396320c7377.
What this PR fixes
- User pain: With
startup.mode = initial/earliestandstop.mode = "latest", every change written during the snapshot phase is silently dropped becauseIncrementalSplit.stopOffsetis frozen at job-start time, socheckStopOffset()terminates the binlog phase immediately. - Fix approach: "Option B" — the enumerator's
IncrementalSplitAssigner.completedSnapshotPhase()now resolvesoffsetFactory.latest()exactly once when the snapshot phase completes, stores it inresolvedStopOffset, stamps it into the incremental split increateIncrementalSplit(), and carries it in a newIncrementalPhaseState.stopOffsetfield for restore. - One-line summary: The core semantics are now right and the enumerator-side design is the correct one, but the new
stopOffsetfield is not wired into the checkpoint state serializer (so the restore guarantee is not actually implemented), theStopConfigfallback increateIncrementalSplit()can still hand out a stale offset before resolution, and the unguardedoffsetFactory.latest()call sits on the enumerator's snapshot-completion path with no retry.
Runtime chain I rechecked
Reader reports snapshot split completion -> enumerator handles the event
IncrementalSourceEnumerator.handleSourceEvent(CompletedSnapshotSplitsReportEvent)
-> HybridSplitAssigner.onCompletedSplits(...) / completedSnapshotPhase check
-> IncrementalSplitAssigner.completedSnapshotPhase(tableIds) IncrementalSplitAssigner.java:322-348 (changed)
-> context.getAssignedSnapshotSplit() / getSplitCompletedOffsets() drained -> completed == true
-> StopConfig.getStopMode() == StopMode.LATEST && resolvedStopOffset == null
-> offsetFactory.latest() [remote DB call, e.g. MySqlConnectionUtils.currentBinlogOffset — no try/catch] IncrementalSplitAssigner.java:342
-> resolvedStopOffset = <post-snapshot binlog position>
Split handout to the reader
HybridSplitAssigner.getNext() -> IncrementalSplitAssigner.getNext()
-> IncrementalSplitAssigner.createIncrementalSplit(...) IncrementalSplitAssigner.java:290-316 (changed)
-> incrementalSplitStopOffset = resolvedStopOffset != null ? resolvedStopOffset : sourceConfig.getStopConfig().getStopOffset(offsetFactory) IncrementalSplitAssigner.java:304-307 [fallback path re-resolves latest() -> stale if split created before completedSnapshotPhase]
-> new IncrementalSplit(..., incrementalSplitStopOffset, ...)
-> reader: IncrementalSourceStreamFetcher -> fetch task's shouldEmit/checkStopOffset compares currentOffset.isAtOrAfter(split.getStopOffset()) -> binlog phase now runs to the post-snapshot position
Checkpoint / restore path (broken link)
IncrementalSplitAssigner.snapshotState(checkpointId) IncrementalSplitAssigner.java:210-212 (changed)
-> new IncrementalPhaseState(startupOffset, resolvedStopOffset) IncrementalPhaseState.java:47-50 (new field)
-> PendingSplitsStateSerializer.serialize(...) [NOT updated in this diff — stopOffset is never written, so a real checkpoint round-trip drops it]
restore: new IncrementalSplitAssigner(context, ..., checkpointState) IncrementalSplitAssigner.java:120-123
-> this.resolvedStopOffset = checkpointState.getStopOffset() [always null after deserialization -> falls back to re-resolving latest() on restore, the exact drift this PR aims to prevent; the unit test passes the state object in-memory and bypasses the serializer, so it cannot catch this]
Findings
Issue 1: New IncrementalPhaseState.stopOffset field is never wired into the checkpoint serializer — the claimed restart stability does not survive a real checkpoint round-trip, and old-checkpoint compatibility is unaddressed
- Location:
seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/state/IncrementalPhaseState.java:39 - Why it matters: - Root cause: the PR adds
stopOffsettoIncrementalPhaseStateand reads it back viacheckpointState.getStopOffset()in the restore constructor, but none of the 7 changed files touchesPendingSplitsStateSerializer(or any serializer). Enumerator state in connector-cdc-base is serialized field-by-field, so the new field is silently dropped when the state is actually written to and restored from a Zeta/Flink checkpoint. - Impact: after a real restore,
resolvedStopOffsetis alwaysnull,createIncrementalSplitfalls back toStopConfig.getStopOffset(offsetFactory), andlatest()is re-resolved at restart time — reintroducing exactly the stop-boundary drift this PR is designed to prevent. The new unit test does not catch this because it hands the state object over in-memory, bypassing serialization entirely. Old checkpoints written before this change also need a defined read path. - Suggested fix:
- (1) serialize/deserialize the optional
stopOffsetinPendingSplitsStateSerializerwith a version bump and a legacy-read path for pre-existing checkpoints; - (2) add a serializer round-trip test;
- (3) confirm a
getStopOffset()accessor is actually generated (e.g. via a class-level@Getter), since only the field and constructors appear in the diff. - Evidence:
seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/state/IncrementalPhaseState.java:35 * stop.mode = latest}). Stored in the checkpoint so that a restart reuses the same value;seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/IncrementalSplitAssigner.java:123 this.resolvedStopOffset = checkpointState == null ? null : checkpointState.getStopOffset();;seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/IncrementalSplitAssigner.java:211 return new IncrementalPhaseState(startupOffset, resolvedStopOffset); - Suggested fix: This field is added to the enumerator state, but I don't see a corresponding change to
PendingSplitsStateSerializerin this PR. Enumerator state is serialized field-by-field, sostopOffsetwill be silently lost on a real checkpoint round-trip — after restorecheckpointState.getStopOffset()returnsnull,createIncrementalSplitfalls back toStopConfig.getStopOffset(offsetFactory), andlatest()gets re-resolved at restart time, reintroducing exactly the drift this design is meant to prevent. The unit test doesn't catch this because it passes the state object directly, bypassing serialization. Please (1) serialize/deserialize the optionalstopOffsetinPendingSplitsStateSerializerwith a version bump and a legacy-read path for pre-existing checkpoints, and (2) add a serializer round-trip test. Also please confirm agetStopOffset()accessor is generated (class-level@Getter) since only the field/constructors are shown here. - Severity: High
Issue 2: Split created before completedSnapshotPhase gets a stale StopConfig offset while the checkpoint stores the later resolvedStopOffset, so a restore can silently change the job's stop boundary; multi-split assignments can also straddle the resolution and stop at different positions
- Location:
seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/IncrementalSplitAssigner.java:307 - Why it matters: - Root cause:
createIncrementalSplitonly usesresolvedStopOffsetif it is already non-null; otherwise it resolves fromStopConfigat split-creation time. The PR's own new unit test demonstrates this window: the firstgetNext()returns a split whose stop offset issplitCreationOffset, thencompletedSnapshotPhaseresolves a differentresolvedOffset, and the restored assigner produces a split stopping atresolvedOffset. - Impact: in that scenario the running reader (pre-restart) stops at the stale
StopConfigoffset while the checkpoint stores the laterresolvedStopOffset, so a restore silently moves the job's stop boundary mid-flight. WithincrementalParallelism > 1, splits created on either side of the resolution can be handed out with different binlog stop positions in the same job. - Suggested fix: make
createIncrementalSplita resolution point as well — when stop mode isLATESTandresolvedStopOffset == null, resolveoffsetFactory.latest()there, store it inresolvedStopOffset, and use it. That guarantees a single authoritative stop offset for all splits and the checkpoint regardless of call ordering. - Evidence:
seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/IncrementalSplitAssigner.java:307 : sourceConfig.getStopConfig().getStopOffset(offsetFactory);;seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/test/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/IncrementalSplitAssignerTest.java:98 splitCreationOffset, assigner.getNext().get().asIncrementalSplit().getStopOffset());;seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/test/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/IncrementalSplitAssignerTest.java:97 splitCreationOffset, assigner.getNext().get().asIncrementalSplit().getStopOffset()); - Suggested fix: If the incremental split is created before
completedSnapshotPhaseruns (your new unit test asserts exactly this: the first split getssplitCreationOffset, thencompletedSnapshotPhaseresolves a different offset), the live reader stops at the stale StopConfig offset while the checkpoint stores the laterresolvedStopOffset— a restore then changes the stop boundary mid-job, and withincrementalParallelism > 1splits straddling the resolution would stop at different binlog positions. Suggest making this a resolution point too: when stop mode isLATESTandresolvedStopOffset == null, resolveoffsetFactory.latest()here, store it inresolvedStopOffset, and use it — that guarantees a single authoritative stop offset for all splits and the checkpoint, independent of call ordering. - Severity: Medium
Issue 3: The e2e "structural readiness gate" is not actually structural — id=1 reaching the sink does not prove the snapshot is still running, so the latest-stop assertion for initial startup remains racy/flaky
- Location:
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-cdc-mysql-e2e/src/test/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/MysqlCDCStopModeSpecificIT.java:394 - Why it matters: - Root cause: the gate waits until row id=1 (
'bulk') is visible in the sink, and the comment claims "this signal can only fire while the snapshot is still reading the remaining splits". That is not guaranteed: 200 tiny rows across 10 splits can be snapshotted end-to-end within a single Awaitility poll interval, so by the time the assertion first observes id=1 in the sink, all splits may already be complete andcompletedSnapshotPhasemay already have resolved the stop offset. - Impact: when the snapshot finishes before the gate fires, the id=21 UPDATE issued afterwards legitimately lands after the resolved stop offset, the
"latest-stop"assertion fails, and the test is flaky — with a failure message that misleadingly suggests data loss rather than a timing miss. - Suggested fix: make the stall deterministic, e.g. hold a row lock on a last-chunk row (id >= 181) in an open transaction while issuing the UPDATE; or at minimum assert a last-chunk row is NOT yet in the sink and fail with an explicit "snapshot finished too early" message.
- Evidence:
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-cdc-mysql-e2e/src/test/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/MysqlCDCStopModeSpecificIT.java:404 queryVarcharById(1),;seatunnel-e2e/seatunnel-connector-v2-e2e/connector-cdc-mysql-e2e/src/test/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/MysqlCDCStopModeSpecificIT.java:430 "latest-stop", - Suggested fix: This claim doesn't hold: seeing id=1 in the sink only proves the first chunk was emitted — 200 tiny rows across 10 splits can finish snapshotting within one Awaitility poll interval, so the whole snapshot (and the stop-offset resolution in
completedSnapshotPhase) may already be done before this gate fires. In that case the id=21 UPDATE legitimately lands after the stop offset and the"latest-stop"assertion below fails — a flaky test. Please make the stall deterministic, e.g. hold a row lock on a last-chunk row (id ≥ 181) in an open transaction while issuing the UPDATE, or at least assert a last-chunk row is NOT yet in the sink and fail with an explicit "snapshot finished too early" message instead of a misleading data-loss failure. - Severity: Medium
Issue 4: User-facing change to stop.mode = latest semantics is not reflected in the connector docs; the PR checklist's docs item is still unchecked
- Location:
seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/IncrementalSplitAssigner.java:343 - Why it matters: - Root cause:
completedSnapshotPhase()now resolves thelateststop offset at snapshot-phase completion instead of at job start, which changes when astop.mode=latestjob terminates forinitial/earlieststartups. No file underdocs/appears in the changed-file list. - Impact:
docs/en/connector-v2/source/MySQL-CDC.md(and thedocs/zh/counterpart) describestop.mode = latestwithout stating at which point the "latest" offset is captured. Users who relied on the old job-start-time behavior will see jobs run longer and consume additional post-snapshot changes with no documented explanation. Since the change lives in connector-cdc-base, it applies to every CDC connector built on it, not just MySQL. - Suggested fix: update the
stop.modedescriptions in the English and Chinese connector docs to state that forinitial/earlieststartups the latest offset is captured once the snapshot phase completes, and mention the behavior change in the release notes. - Evidence:
seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/IncrementalSplitAssigner.java:339 // stop.mode=latest: resolve the stop offset once, now that the snapshot phase is;seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/IncrementalSplitAssigner.java:336 if (completed - Suggested fix: This changes the user-observable stop boundary of
stop.mode = latest(now resolved at snapshot completion rather than job start), but no doc file is touched in this PR. Please update thestop.modedescription indocs/en/connector-v2/source/MySQL-CDC.mdand the zh counterpart to state that forinitial/earlieststartups the latest offset is captured once the snapshot phase completes, and add a line to the release notes — this applies to all CDC connectors built on connector-cdc-base. - Severity: Medium
Issue 5: offsetFactory.latest() is called on the enumerator's snapshot-completion path with no exception handling or retry — a transient DB failure at the exact snapshot→incremental transition point fails the whole job
- Location:
seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/IncrementalSplitAssigner.java:344 - Why it matters: - Root cause:
completedSnapshotPhase()now performs a remote database call (offsetFactory.latest()opens a JDBC connection and queries the current binlog position for MySQL) inside the enumerator's event-handling path, right after mutatingcontext.getAssignedSnapshotSplit()/getSplitCompletedOffsets(). - Impact: a momentary network blip or connection-limit rejection at the precise moment the last snapshot split completes throws out of the enumerator's event handler and fails the job — after the entire (potentially large) snapshot has already been read, wasting all of that work at the single worst moment to fail.
- Suggested fix: wrap the call in a bounded retry with backoff, or move the once-only resolution into
createIncrementalSplit(guarded byresolvedStopOffset == null), where the reader's split-request loop naturally retries. - Evidence:
seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/IncrementalSplitAssigner.java:336 if (completed;seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/IncrementalSplitAssigner.java:338 && context.getSourceConfig().getStopConfig().getStopMode() == StopMode.LATEST) { - Suggested fix:
offsetFactory.latest()performs a live database query (SHOW MASTER STATUS via a fresh JDBC connection for MySQL), and here it runs on the enumerator's completion-handling path with no try/catch or retry. A transient connection failure at the moment the last snapshot split completes will throw out of the event handler and fail the job after the full snapshot has already been read. Please add a bounded retry with backoff here, or move the once-only resolution intocreateIncrementalSplit(guarded byresolvedStopOffset == null) where the reader's split-request loop naturally retries. - Severity: Medium
Issue 6: Restore test bypasses the state serializer, so it cannot detect that the new stopOffset is dropped by a real checkpoint round trip
- Location:
seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/test/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/IncrementalSplitAssignerTest.java:105 - Why it matters: - Root cause:
shouldResolveLatestStopOffsetOnceAtSnapshotCompletionAndReuseAfterRestoretakes theIncrementalPhaseStatereturned bysnapshotState(1L)and passes the same in-memory object directly into the restored assigner's constructor, skippingPendingSplitsStateSerializerentirely. - Impact: the test asserts the drift-free restore contract (
assertSame(resolvedOffset, ...)) but would still pass even though the serializer never persistsstopOffset— giving false confidence that the restore guarantee holds when a real checkpoint round-trip would in fact lose the value. - Suggested fix: serialize and deserialize the state within the test (or add a dedicated
PendingSplitsStateSerializerround-trip test) so the "reuse after restore" contract is verified against the actual persistence path. - Evidence:
seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/test/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/IncrementalSplitAssignerTest.java:110 createContext(sourceConfig), 1, offsetFactory, checkpoint); - Suggested fix: This restore test hands the in-memory
IncrementalPhaseStateobject straight to the restored assigner, so it never exercisesPendingSplitsStateSerializer. Since that serializer currently does not persist the newstopOffset, the test passes while a real checkpoint restore would lose the value. Please serialize/deserialize the state here (or add a serializer round-trip test) so the "reuse after restore" contract is verified against the actual persistence path. - Severity: Medium
Issue 7: PR description should be aligned with the final enumerator-side implementation and with the initial-only scope of the post-snapshot e2e assertion
- Location:
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-cdc-mysql-e2e/src/test/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/MysqlCDCStopModeSpecificIT.java:416 - Why it matters: - Root cause: the final implementation resolves the stop offset once in the enumerator's
completedSnapshotPhase(); no reader-side file (e.g.MySqlBinlogFetchTaskorBoundedMySqlStreamingChangeEventSource) is among the 7 changed files. Separately, the in-code comment inMysqlCDCStopModeSpecificITexplains that only theinitialstartup mode deterministically asserts the post-snapshot change; theearliestcase does not carry the same guarantee. - Impact: the PR description typically becomes the squash-merge commit message; if it describes a reader-side mechanism or a broader assertion scope than the diff actually implements, anyone later debugging
stop.mode=latestbehavior or auditing test coverage will be misled. - Suggested fix: verify the PR description describes the enumerator-side resolution in
completedSnapshotPhase()and scopes the post-snapshot e2e assertion claim toinitialonly, updating it if it does not. - Evidence:
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-cdc-mysql-e2e/src/test/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/MysqlCDCStopModeSpecificIT.java:416 // update — not a deterministic contract, therefore not asserted. - Suggested fix: The in-code rationale here — only
initialdeterministically asserts the post-snapshot change — is correct. Since the final fix lives in the enumerator (completedSnapshotPhase()) and no reader-side files are touched in this diff, please make sure the PR description (and thus the squash-merge commit message and release notes) describes this enumerator-side mechanism and scopes the assertion-coverage claim toinitialonly. - Severity: Low
Issue 8: Diff contains no changes to MySqlBinlogFetchTask / BoundedMySqlStreamingChangeEventSource — ensure the PR description does not attribute the fix to a reader-side mechanism, or the merged commit message will misdescribe it
- Location:
seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/IncrementalSplitAssigner.java:339 // stop.mode=latest: resolve the stop offset once, now that the snapshot phase is - Why it matters: - Root cause: the merged mechanism is enumerator-side resolution in
IncrementalSplitAssigner.completedSnapshotPhase(); none of the 7 changed files touches the MySQL connector's fetch task or streaming change event source. - Impact: the PR description usually becomes the squash-merge commit message. If it attributes the fix to
MySqlBinlogFetchTask.execute()/BoundedMySqlStreamingChangeEventSource, anyone debuggingstop.mode=latestbehavior later would look in the wrong layer (reader-side fetch task) instead of the enumerator's split-assignment path, and would also wrongly assume the fix is MySQL-specific rather than applying to all connector-cdc-base connectors. - Suggested fix: verify the PR description names
IncrementalSplitAssigner.completedSnapshotPhase()/createIncrementalSplit()as the fix location and notes that the change applies to all CDC connectors built on connector-cdc-base, updating it before merge if it does not. - Evidence:
seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/IncrementalSplitAssigner.java:301 // stop.mode=latest: use the offset resolved once when the snapshot phase completed - Severity: Low
Review conclusion
Conclusion: can merge after the blocking items are fixed
1. Blocking items
- Issue 1: New
IncrementalPhaseState.stopOffsetfield is never wired into the checkpoint serializer — the claimed restart stability does not survive a real checkpoint round-trip, and old-checkpoint compatibility is unaddressed
2. Remaining follow-ups
- Issue 2: Split created before
completedSnapshotPhasegets a stale StopConfig offset while the checkpoint stores the laterresolvedStopOffset, so a restore can silently change the job's stop boundary; multi-split assignments can also straddle the resolution and stop at different positions - Issue 3: The e2e "structural readiness gate" is not actually structural — id=1 reaching the sink does not prove the snapshot is still running, so the
latest-stopassertion forinitialstartup remains racy/flaky - Issue 4: User-facing change to
stop.mode = latestsemantics is not reflected in the connector docs; the PR checklist's docs item is still unchecked - Issue 5:
offsetFactory.latest()is called on the enumerator's snapshot-completion path with no exception handling or retry — a transient DB failure at the exact snapshot→incremental transition point fails the whole job - Issue 6: Restore test bypasses the state serializer, so it cannot detect that the new
stopOffsetis dropped by a real checkpoint round trip - Issue 7: PR description should be aligned with the final enumerator-side implementation and with the
initial-only scope of the post-snapshot e2e assertion - Issue 8: Diff contains no changes to
MySqlBinlogFetchTask/BoundedMySqlStreamingChangeEventSource— ensure the PR description does not attribute the fix to a reader-side mechanism, or the merged commit message will misdescribe it
Thanks for the updates so far. Happy to discuss the remaining points.
|
Thanks for the very thorough round of review, @SEZ9 — this pushed me to re-verify my own round-2/round-3 conclusions against the actual source rather than trusting my earlier read, and the result is a mix: one of your findings turns out not to hold up, but another is a real gap I missed. Splitting it out: Issue 1 / Issue 6 (checkpoint serializer) — I don't think this holds up; pushing back with evidence Both issues are built on the premise that enumerator state is persisted through a hand-written, field-by-field What actually persists this state is plain Java serialization: Given there's no serializer to bypass, Issue 2 (stale offset for the pre-resolution split, restore boundary drift) — you're right, and I missed this in rounds 2/3. Conceding with thanks. I re-traced the actual call order rather than relying on the author's explanation this time, and it confirms your read:
So the ordering isn't just possible, it's effectively the normal path with the default I haven't independently re-verified Issues 3/4/5/7/8 in this pass — this reply is scoped to the two points above where the review's conclusion needed direct confirmation. @li3zhi4, given Issue 2 is confirmed real, I'd suggest prioritizing that fix; happy to take another full pass once it's addressed. |
…ix (PR apache#11885) Addresses every finding from the round-3 (DanielLeens) and round-4 (SEZ9) reviews: - NPE in completedSnapshotPhase: the stop.mode=latest resolution moved out of completedSnapshotPhase entirely (into createIncrementalSplit), so the method no longer dereferences context.getSourceConfig(); HybridSplitAssignerTest now supplies a mocked SourceConfig (StopMode.NEVER) to keep the test's intent explicit (DanielLeens round-3 Issue 1, High). - Single authoritative stop-offset resolution point (SEZ9 Issue 2, confirmed real by DanielLeens): createIncrementalSplit resolves latest() exactly once when resolvedStopOffset == null and reuses it for every split and the checkpoint. The split handed to the reader and the checkpointed value can no longer diverge, so a restore cannot silently move the stop boundary. - Retry/backoff around the latest() resolution (SEZ9 Issue 5): a transient DB failure at the snapshot-to-incremental transition is retried 3x instead of failing the whole job (mirrors the connection-factory retry pattern). - Serialization round-trip unit test (SEZ9 Issue 6): IncrementalPhaseStateTest proves stopOffset survives a real Java serialization round-trip and that a legacy single-arg state deserializes with stopOffset == null (unchanged serialVersionUID, plain Java field evolution - there is no hand-written serializer in connector-cdc-base, per DanielLeens' verification). - Deterministic e2e readiness for initial (SEZ9 Issue 3): 2000-row bulk (snapshot.split.size=20 -> 100 splits) so the sink-visibility gate fires with ~99 splits unread, plus a defensive assertion that the last-chunk row is not yet in the sink (fails loudly with "snapshot finished too early" instead of a misleading data-loss message). Row-lock stalls are not usable: the snapshot reader issues a plain MVCC SELECT, so FOR UPDATE does not block it. - Docs (SEZ9 Issue 4): stop.mode=latest snapshot-window semantics documented in MySQL-CDC.md (en/zh). - PR description aligned with the enumerator-side implementation (SEZ9 Issues 7/8). Verified: spotless:check, cdc-base unit tests 71/71, e2e 7/7 (initial+earliest 2/2, latest+specific+timestamp 3/3, specific regression 2/2), git diff --check clean. Co-Authored-By: AtomCode (deepseek-v4-flash) <noreply@atomgit.com>
|
Thanks to both @DanielLeens and @SEZ9 for the thorough round-3/round-4 reviews. All findings are now addressed on head DanielLeens round-3 Issue 1 (NPE in SEZ9 Issue 2 / DanielLeens confirmation (single authoritative resolution point) — fixed, and it also subsumes the NPE fix above. SEZ9 Issue 1 / Issue 6 (checkpoint serialization) — as @DanielLeens verified, SEZ9 Issue 3 (readiness gate not structural) — addressed. Two changes: (1) the SEZ9 Issue 4 (docs) — done. SEZ9 Issue 5 (no exception handling on SEZ9 Issue 7 / Issue 8 (PR description alignment) — done. The PR description now describes the enumerator-side mechanism ( Verification (local, head |
DanielLeens
left a comment
There was a problem hiding this comment.
What Problem Does This PR Solve?
MySQL-CDC's stop.mode = "latest", combined with a snapshot-taking startup (startup.mode = initial or earliest), silently drops every change written to the source while the snapshot phase is running: the incremental split's stop offset was resolved via offsetFactory.latest() at incremental-split creation and frozen into a final field, so the bounded binlog reader's checkStopOffset() immediately saw currentBinlogOffset.isAtOrAfter(stopOffset) and terminated the job right after the snapshot, before reading any post-snapshot change. Fix approach: resolve the latest stop offset exactly once, at the enumerator's IncrementalSplitAssigner.createIncrementalSplit(), cache it for every subsequent split in the same job and for the checkpoint, and add a bounded retry so a transient DB hiccup at that exact transition point doesn't fail the whole job. One-sentence summary: moves the single point of truth for the resolved "latest" stop offset from a per-call live query to a once-resolved, checkpoint-carried value, closing the data-loss window.
I reviewed the current head a090452 in full, tracing the runtime call chain from scratch rather than diffing against my (or SEZ9's) earlier reviews. This PR has been through several rounds — including a full architecture change (reader-side resolution in commit 5e5d9f0, then moved to enumerator-side in c58fc10 per earlier review feedback, then a further internal move within the enumerator in the latest commit a090452 after both my round-3 and SEZ9's round-4 reviews) — so I want to be explicit that everything below is checked against the code as it stands right now, not carried forward from memory. Folding in the acknowledgment from my own prior comment (2026-08-23): I had already pushed back on SEZ9's Issues 1/6 (no hand-written checkpoint serializer exists in connector-cdc-base — PendingSplitsState extends Serializable and the state is plain-Java-serialized, so there is nothing to "wire into") and conceded SEZ9's Issue 2 was real (a genuine race between completedSnapshotPhase()'s resolution and createIncrementalSplit()'s separate resolution). I re-verified both of those conclusions against the current head rather than assuming they still hold, and independently re-derived the same call chain.
1. Code Change Review
1.1 Core Logic Analysis
Core change, IncrementalSplitAssigner.java:
// createIncrementalSplit(), current head
if (resolvedStopOffset == null
&& sourceConfig.getStopConfig().getStopMode() == StopMode.LATEST) {
resolvedStopOffset = resolveLatestStopOffsetWithRetry(sourceConfig);
LOG.info("stop.mode=latest: resolved stop offset {} at incremental split creation", resolvedStopOffset);
}
Offset incrementalSplitStopOffset =
resolvedStopOffset != null
? resolvedStopOffset
: sourceConfig.getStopConfig().getStopOffset(offsetFactory);plus a new resolvedStopOffset field carried through both constructors (fresh vs. restored-from-checkpoint), a 3-attempt retry-with-backoff around the live offsetFactory.latest() query, and a matching stopOffset field added to IncrementalPhaseState with the serialVersionUID explicitly preserved.
Runtime path I verified for a fresh (non-restart) run — confirms the single-resolution-point design is correct:
HybridSplitAssigner.getNext() HybridSplitAssigner.java:99-117
snapshotSplitAssigner.noMoreSplits() == true (all splits assigned)
snapshotSplitAssigner.isCompleted() == true SnapshotSplitAssigner.java:279
-> assignedSplits.size() == splitCompletedOffsets.size() SnapshotSplitAssigner.java:290
(i.e. every assigned split has actually reported back a completion watermark,
not merely been handed out -- this really does gate on snapshot READ completion)
-> incrementalSplitAssigner.getNext() IncrementalSplitAssigner.java:131-148
-> createIncrementalSplits(startWithSnapshotMinimumOffset) IncrementalSplitAssigner.java:222-242
-> createIncrementalSplit(capturedTable, i, ...) [loop, one call per parallel subtask]
-> resolvedStopOffset == null -> resolveLatestStopOffsetWithRetry(sourceConfig)
-> sourceConfig.getStopConfig().getStopOffset(offsetFactory) -> offsetFactory.latest()
[fresh JDBC connection, live SHOW MASTER STATUS-equivalent]
-> resolvedStopOffset cached on the assigner instance; EVERY subsequent
createIncrementalSplit() call in the SAME createIncrementalSplits() loop
(i.e. every parallel split, for incrementalParallelism > 1) reuses the
identical cached value -- so parallel readers cannot be handed
divergent stop boundaries, which a naive per-task resolution
(the literal fix originally proposed in issue #11884) would risk.
I confirmed HybridSplitAssigner.getNext() only calls into the incremental assigner after isCompleted() — genuine read-completion, not mere assignment — so the resolution point really is "at binlog phase start" as the PR title claims, and it is architecturally better than the issue's own originally-proposed per-task (MySqlBinlogFetchTask.execute()) resolution: a single authoritative value avoids the divergent-parallel-readers risk entirely. I also confirmed the reader side needs no change for this to work: MySqlBinlogFetchTask.checkStopOffset() only ever compares against binlogSplit.getStopOffset() (the value the enumerator already baked into the split) — it never independently re-queries latest() — so fixing the enumerator's resolution value is both necessary and sufficient.
Runtime path for a checkpoint restart (the part SEZ9's Issue 2 was about, and the part the latest commit specifically re-architected):
new IncrementalSplitAssigner(context, parallelism, offsetFactory, checkpointState) IncrementalSplitAssigner.java:114-125
resolvedStopOffset = checkpointState.getStopOffset() // non-null if checkpointed post-fix, null for a legacy pre-fix checkpoint
...
getNext() -> createIncrementalSplit(): resolvedStopOffset != null -> reused as-is, offsetFactory.latest() NOT called again
Because the resolution and the split-creation now happen in the same method (createIncrementalSplit), there is no longer a window where one call resolves a value for the live split and a separate call (completedSnapshotPhase, in the previous iteration of this PR) resolves a second, different value purely for the checkpoint — which is exactly the restart-drift bug SEZ9's Issue 2 identified against the prior commit. I re-traced this myself against the current head rather than taking the commit message's claim at face value, and it holds: there is now exactly one call site (createIncrementalSplit, guarded by resolvedStopOffset == null) that can ever call offsetFactory.latest() for a given assigner instance.
On SEZ9's Issues 1/6 (checkpoint serializer) — I re-verified this independently rather than relying on my own prior comment: PendingSplitsState (.../enumerator/state/PendingSplitsState.java) is public interface PendingSplitsState extends Serializable {}, a bare marker interface. I searched the dev tree for any *Serializer* class under connector-cdc-base's enumerator package and found none — IncrementalPhaseState/HybridPendingSplitsState/SnapshotPhaseState are persisted via plain Java object serialization, not a hand-written byte-level codec. With serialVersionUID explicitly held at -6809026812298443356L (unchanged from before this PR — I diff'd it against dev), standard Java field-evolution means an old stream (written before stopOffset existed) deserializes with stopOffset = null, which is exactly what IncrementalPhaseStateTest.shouldDefaultStopOffsetToNullOnLegacySerializedState proves via a real ObjectOutputStream/ObjectInputStream round trip — not an in-memory pass-through. So there is no "serializer to wire into" here; the new field is automatically covered by the existing persistence mechanism, and the test genuinely exercises it. I agree with the PR's resolution of both issues.
1.2 Compatibility Impact
Fully compatible.
stop.mode's accepted values, defaults, and behavior forspecific/timestamp/neverare unchanged (createIncrementalSplit's fallback branch is untouched for non-LATESTmodes).IncrementalPhaseState's explicit, unchangedserialVersionUIDplus the new field defaulting tonullon deserialization of an old checkpoint is the correct backward-compatible pattern, and is the one part of this PR with a dedicated regression test (shouldDefaultStopOffsetToNullOnLegacySerializedState) proving it — good practice, not just an assertion in the PR description.- A legacy checkpoint restored under the new code (
resolvedStopOffset == nullfrom deserialization) falls through tocreateIncrementalSplit's live-resolution branch exactly as a fresh run would, so upgrading mid-flight doesn't throw or corrupt state — it just re-resolves once, which is the same "resolve once, going forward" behavior as before this fix existed for that specific checkpoint. - One asymmetry I found, not previously raised, that only matters for a narrow upgrade scenario:
addSplits()(IncrementalSplitAssigner.java:175-208) restoresthis.startupOffsetfrom an already-assigned incoming split'sgetStartupOffset()ifstartupOffsetis stillnull, but has no equivalent restoration forresolvedStopOffsetfromincrementalSplit.getStopOffset(). This only matters if: (a) a job is upgraded across this fix while restoring a legacy checkpoint (resolvedStopOffsetstartsnull) that already had an in-flight, previously-assigned incremental split (restored viaaddSplits, not freshly created), and (b)incrementalParallelism > 1so other capturedTable groups still need a new split created viacreateIncrementalSplit. In that specific combination, the already-assigned split (from before the upgrade) keeps whatever stop offset the old code baked into it, while the newly-created split(s) for the remaining table groups would resolve a fresh (later)latest()value — i.e., different parallel incremental readers in the same post-upgrade job could stop at different binlog positions. This is narrow (requires hitting the upgrade boundary mid-flight with parallelism > 1) and I'm not treating it as blocking, but it's worth a short follow-up.
1.3 Performance / Side-Effect Analysis
resolveLatestStopOffsetWithRetry runs Thread.sleep(300L * attempt) (up to ~900ms cumulative across 2 sleeps before the 3rd/final attempt) on the calling thread when offsetFactory.latest() fails transiently. This method is called from createIncrementalSplit(), which runs on the split-enumerator's coordinator-side callback path — a brief, bounded block here (at most once per job, only on the rare snapshot-to-incremental transition, and only when the DB call is actively failing) is a reasonable trade-off against failing the whole job outright, but it is worth confirming this enumerator callback isn't shared across multiple concurrently-running CDC sources on the same coordinator thread pool in the Zeta engine — if it is, a stuck/slow-retrying MySQL source could very briefly delay other sources' split assignment. I'd call this a minor, non-blocking note rather than a real risk given the small bound (900ms) and rarity.
1.4 Error Handling and Logging
No blocking issues found. The one new item from this pass:
Issue 1: addSplits() does not restore resolvedStopOffset from an already-assigned split's stop offset, unlike the symmetric handling for startupOffset, creating a narrow window for diverging parallel stop-offsets across an upgrade boundary
- Location:
seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/IncrementalSplitAssigner.java:174-208 - Potential risk: with
incrementalParallelism > 1, restoring a legacy (pre-this-fix) checkpoint that has an in-flight incremental split could leave that split's already-baked-in stop offset out of sync with a freshly-resolved value used for other parallel splits created after the restart. - Best improvement: mirror the
startupOffsetpattern inaddSplits()— ifresolvedStopOffset == nulland an incoming split carries a non-neverStop()stop offset consistent withStopMode.LATEST, adopt it the same waystartupOffsetis adopted. - Severity: Low (requires hitting the exact upgrade-boundary + multi-parallelism combination; does not affect a same-version restart or
incrementalParallelism == 1, which is the common case for MySQL CDC binlog reading) - Raised by another reviewer: No
2. Code Quality Assessment
2.1 Coding Standards
New fields/methods have adequate Javadoc explaining the why (e.g., resolvedStopOffset's comment explicitly states it exists to avoid restart drift; resolveLatestStopOffsetWithRetry's comment explains why retry is needed at this specific transition point). IncrementalPhaseState's new stopOffset field's Javadoc correctly documents the legacy-checkpoint null case. This meets the project's comment-density bar for checkpoint/recovery-adjacent fields.
2.2 Test Coverage and Test Stability
Coverage is thorough and specifically targeted at the failure modes this PR is fixing:
IncrementalSplitAssignerTest.shouldResolveLatestStopOffsetOnceAtSplitCreationAndReuseAfterRestoreasserts, viaMockito.verify(offsetFactory, times(1)).latest(), that the resolution genuinely happens exactly once across both a fresh run and a restore — a precise, non-trivial assertion, not just an existence check.IncrementalPhaseStateTestexercises realObjectOutputStream/ObjectInputStreamround trips for both the new-field and legacy-field-absent cases — this is exactly the right way to prove the compatibility claim, and directly answers SEZ9's Issue 6 concern about the restore test bypassing "the serializer" (there is none to bypass, and this test proves it via the actual persistence mechanism).HybridSplitAssignerTest's updated mock (StopConfig(StopMode.NEVER, ...)) avoids an NPE now thatcompletedSnapshotPhase()no longer touchessourceConfigat all — correct, though the accompanying comment ("must not trigger the stop.mode=latest resolution inIncrementalSplitAssigner.completedSnapshotPhase") slightly overstates the mechanism:completedSnapshotPhase()in the current head doesn't referencesourceConfig/StopConfigat any point, so there's nothing there to "trigger" — the real reason a non-null mock is needed is more likely defensive/consistency with the class's other usages. Very minor, non-blocking wording nit.
Stability rating: Stable. No Thread.sleep in the unit tests, no nondeterministic assertions, no shared static state.
For the E2E test (MysqlCDCStopModeSpecificIT), I specifically checked the readiness-gate design SEZ9's Issue 3 flagged against the prior commit: the current version bulk-inserts 2000 rows with snapshot.split.size = 20 (100 splits), waits for row id=1 to reach the sink, and then adds a defensive assertion that row id=2000 (last chunk) is not yet in the sink — failing loudly with "snapshot finished too early" rather than letting a false-negative "data loss" failure mislead. With 100 splits consumed in ascending-key order and only the first split's completion needed to satisfy the readiness gate, the remaining ~99 splits provide a wide margin before the snapshot could plausibly complete within one Awaitility poll interval — this is a materially more deterministic design than the 10-split/200-row version SEZ9 reviewed, and the comments explaining why 2000 rows/100 splits were chosen (rather than just picking a bigger number) show real engineering rigor. I'm satisfied this specific flakiness concern is resolved; rating Stable for this test.
2.3 Documentation Updates
Both docs/en and docs/zh MySQL-CDC.md are updated with matching content (checked side by side): the stop.mode table row now states that for a snapshot-taking startup, the stop offset is resolved once the snapshot phase completes, and a full worked HOCON example is added right after the existing bounded-read section. This directly and correctly addresses SEZ9's Issue 4.
3. Architectural Soundness
3.1 Elegance of the Solution
Precise fix, and a better one than the issue's own originally-proposed reader-side mechanism: resolving once in the enumerator (the single point that creates every incremental split for a job) is structurally simpler than resolving independently per parallel task, and avoids a whole class of divergent-boundary bugs the original proposal would have been exposed to under incrementalParallelism > 1. The fix also correctly generalizes to every CDC connector built on connector-cdc-base (not just MySQL), which the PR description explicitly and accurately calls out.
3.2 Maintainability
High. The single-resolution-point pattern (resolvedStopOffset == null guard) mirrors the pre-existing startupOffset handling in the same class, so a future maintainer reading this file will recognize the pattern immediately rather than learning a new one.
3.3 Extensibility
No new extension points needed or introduced; the fix stays entirely within the existing StopConfig/OffsetFactory abstractions.
3.4 Historical-Version Compatibility
Verified via the dedicated serialization round-trip tests (see 1.2/2.2) — legacy checkpoints deserialize cleanly with stopOffset = null and fall through to the pre-existing resolution path. The one gap I found (Issue 1, addSplits() asymmetry) is narrow and non-blocking rather than a general compatibility break.
4. Issue Summary
| Number | Issue | Location | Severity |
|---|---|---|---|
| 1 | addSplits() doesn't restore resolvedStopOffset from an in-flight split, unlike startupOffset, for a narrow upgrade + incrementalParallelism > 1 scenario |
IncrementalSplitAssigner.java:174-208 |
Low |
| 2 | Minor: HybridSplitAssignerTest's new comment slightly overstates why the non-null StopConfig mock is needed |
HybridSplitAssignerTest.java |
Low |
| 3 | Minor: brief retry-induced Thread.sleep on the enumerator callback path — worth confirming this callback isn't shared across concurrently-running sources on the same coordinator thread pool |
IncrementalSplitAssigner.java:363-388 |
Low |
5. Merge Recommendation
Conclusion: Ready to merge
I disagree with SEZ9's CHANGES_REQUESTED verdict as it stands today, but only because the current head (a090452, pushed after SEZ9's review) already implements the fix SEZ9's own review asked for — I independently re-traced Issues 1/2/5/6 against this head and confirm all four are resolved (Issues 3/4/7/8 I also independently checked and confirm resolved: the E2E readiness gate is now structurally sound, docs are updated, and the PR description accurately attributes the fix to the enumerator-side mechanism). SEZ9's review was correct and valuable against the commit it reviewed; it just hasn't caught up with the subsequent fix yet. My own prior round-3 review is likewise superseded — I had correctly pushed back on Issues 1/6 and correctly conceded Issue 2, and this head is the result of that exchange.
1. Blockers — must be fixed
- None.
2. Recommended fixes — non-blocking
- Issue 1: mirror
startupOffset's restoration pattern forresolvedStopOffsetinaddSplits(), for the narrow legacy-checkpoint + multi-parallelism upgrade case. - Issue 2/3: minor comment accuracy and a thread-pool-sharing sanity check.
CI: the fork's Build check is currently reported as FAILURE, but the only test failure in the run is PostgresCDCIT.testPostgresCdcSnapshotOnlyAndCommittedOffsetStartupModes (ConditionTimeoutException, expected: <1> but was: <0>) — a Postgres-CDC committed-offset/restore test, unrelated to this PR's MySQL-only diff. This exact test is already tracked as a known bug in issue #11847 ("Committed-offset restore can silently skip a row committed after savepoint"), with an open (not yet merged) fix at PR #11864. I'd recommend rerunning this specific job once #11864 merges, or re-triggering CI now in case it's also intermittently flaky — no code change is needed in this PR to address it.
Overall assessment: this is now a well-engineered, thoroughly tested fix that has visibly benefited from two rounds of adversarial review — the final design (single resolution point inside createIncrementalSplit) is demonstrably more robust than either the issue's original proposal or the PR's own first two implementation attempts. I'd merge once CI is green (pending the unrelated Postgres flake above), with the two Low-severity items as optional follow-ups.
|
Quick follow-up on my approval above. At the time I approved (commit a090452, same head as now), the fork's Since then, CI was rerun on this exact same head commit and the One thing still keeping |
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks for pushing this update! I re-reviewed the new commit bbf1bd5b in full against the previously-approved head a090452, retracing the whole call chain rather than just diffing — this is my fourth pass on this PR, and I want to make sure nothing regressed on the way to closing out the last round's follow-ups.
What Problem Does This PR Solve?
- User pain point: MySQL-CDC's
stop.mode = "latest", combined with a snapshot-taking startup (startup.mode = initial/earliest), silently drops every change written to the source table while the snapshot phase is still running, because the stop offset used to be resolved at job-start time (already stale by the time the binlog phase begins) and the bounded reader terminates immediately without reading any post-snapshot change. - Fix approach:
IncrementalSplitAssigner.createIncrementalSplit()resolvesstop.mode=latestexactly once, at the moment the first incremental split is actually created (i.e. genuinely after the snapshot phase has finished, not at job start), caches it on the assigner instance and in the checkpoint (IncrementalPhaseState) so a restart reuses the same value instead of re-resolving (and drifting) it, and wraps the livelatest()query in a bounded retry. - One-sentence summary: this closes the "stop.mode=latest drops post-snapshot changes" data-loss window by moving the single point of truth for the resolved stop offset from a per-call/job-start live query to a once-resolved, checkpoint-carried value.
1. Code Change Review
1.1 Core Logic Analysis
This specific commit only touches two files:
// IncrementalSplitAssigner.addSplits(), new branch (L199-212)
if (this.startupOffset == null) {
this.startupOffset = startupOffset;
}
// Mirror the startupOffset restoration for the resolved latest
// stop offset: a checkpoint written before the stopOffset field
// existed has none, so on restore the re-created incremental
// split carries the previously resolved stop offset. Reuse it
// here instead of re-resolving (and drifting) at split creation.
if (resolvedStopOffset == null
&& context.getSourceConfig() != null
&& context.getSourceConfig().getStopConfig().getStopMode()
== StopMode.LATEST
&& incrementalSplit.getStopOffset() != null) {
resolvedStopOffset = incrementalSplit.getStopOffset();
}plus a Javadoc addition on resolveLatestStopOffsetWithRetry() documenting the threading model, and a comment-accuracy fix in HybridSplitAssignerTest.
This is exactly the three Low-severity, non-blocking follow-ups I left on the previous head (a090452) — I verified each one individually against the actual diff, not just against the commit message:
addSplits()now mirrorsstartupOffset's restoration forresolvedStopOffset. I tracedaddSplits()'s only caller,IncrementalSourceEnumerator.addSplitsBack()(IncrementalSourceEnumerator.java:87-89) — this fires when a previously-assigned split is handed back to a still-running enumerator (e.g. a reader task failure/retry within the same job run), not only on a full job restart. The scenario this closes: a job restored from a legacy (pre-this-PR) checkpoint hasresolvedStopOffset == nullon the newly-constructed assigner; if a reader task carrying an already-assigned incremental split fails before any other table group callscreateIncrementalSplit(), the old code would let that other group's split resolve a fresh (later)latest()value while the re-added split keeps its own, older, already-baked-in stop offset — i.e. two parallel incremental readers stopping at different binlog positions after the same restore. The new branch closes exactly that gap by adopting the incoming split's ownstopOffsetas the assigner'sresolvedStopOffsetbefore any other group gets a chance to resolve a divergent one. The guard set (resolvedStopOffset == null,sourceConfig != null,StopMode.LATEST, non-null incomingstopOffset) correctly scopes this to only the legacy-restore case — a fresh run or an already-resolved restore never reaches this branch, so the steady-state single-resolution-point design from the previous round is untouched.HybridSplitAssignerTest's comment no longer claimscompletedSnapshotPhase()would NPE on the mock — correct, since (as I confirmed in the last round) thestop.mode=latestresolution lives entirely increateIncrementalSplit, notcompletedSnapshotPhase, which never touchessourceConfigat all in the current architecture.- Threading-model Javadoc on
resolveLatestStopOffsetWithRetry()now states explicitly that this runs on the job's own per-job split-enumerator coordinator thread, not a thread pool shared across concurrently running sources — I checkedIncrementalSourceEnumerator/HybridSplitAssigner's call path and this matches: each CDC source gets its ownSplitEnumeratorContext/coordinator, so the bounded (≤900ms) blocking retry only ever delays that job's own split assignment, never another job's.
Key findings:
- The normal (non-restart, single-parallelism) path is unaffected by this commit —
resolvedStopOffsetis still resolved exactly once increateIncrementalSplit(), as verified in the previous round. - The new
addSplits()branch only activates on the narrow legacy-checkpoint-restore-plus-in-flight-task-failure path; it does not change behavior for a same-version restart or forincrementalParallelism == 1(the common MySQL CDC configuration). - This is a precise, targeted fix for the exact gap I raised last round — not a workaround and not a new mechanism, it reuses the same restoration pattern already established for
startupOffsetin the same method. - One thing this commit does not add: any direct test for the new branch (see Issue 1 below) — the underlying single-resolution-point mechanism remains well tested (unchanged from the prior round), but this specific incremental change ships without its own regression test.
In-depth correctness analysis — I re-verified checkStopOffset() in MySqlBinlogFetchTask.java:519-527 is untouched by this whole PR (still just currentBinlogOffset.isAtOrAfter(binlogSplit.getStopOffset()), comparing only against the value the enumerator already baked into the split at creation time). Since the reader never re-queries latest() itself, correctness here depends entirely on the enumerator handing out a single consistent stopOffset for every split in a job — which is exactly the invariant this commit protects for the legacy-restore-plus-task-failure case.
1.2 Compatibility Impact
Fully compatible.
- No API, config, default value, protocol, or serialization format changes in this commit.
IncrementalPhaseStateitself (the checkpoint-serialized class) is untouched here — this commit only changes in-memory restoration logic insideaddSplits(), which runs after deserialization, not the serialized shape. - Historical behavior for non-
LATESTstop modes is unaffected — the new branch is gated onStopMode.LATESTand does nothing otherwise. - A legacy checkpoint (pre-this-PR-entirely, i.e.
IncrementalPhaseStatedidn't even have astopOffsetfield) still deserializes withresolvedStopOffset == nullexactly as before; this commit only changes what happens after that, whenaddSplits()is invoked with an in-flight split for a different table group. No new incompatibility introduced.
1.3 Performance / Side-Effect Analysis
No new performance or resource-usage surface: the new branch is a plain field assignment inside an existing loop over incoming splits (addSplits()), no I/O, no locking, no additional allocation of note. The threading-model Javadoc addition is documentation only.
1.4 Error Handling and Logging
No new exception paths introduced. Findings below.
Issue 1: The new addSplits() legacy-restore branch has no dedicated unit test
- Location:
seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/IncrementalSplitAssigner.java:199-212 - Problem description: I checked every test file under
connector-cdc-base/src/testthat callsaddSplits(...)on anIncrementalSplitAssigner— there are none (addSplits()is only exercised forSnapshotSplitAssignerinSnapshotSplitAssignerTest.java).IncrementalSplitAssignerTest.java(which does have a good, targeted test for thecreateIncrementalSplit()-side single-resolution behavior,shouldResolveLatestStopOffsetOnceAtSplitCreationAndReuseAfterRestore) was not extended to cover this commit's new branch at all — the diff only touches a comment inHybridSplitAssignerTest.java, unrelated to this code path. - Potential risk: this is precisely the checkpoint/recovery-adjacent branch that closes a real (if narrow) upgrade-time divergence risk I flagged last round. Without a regression test, a future refactor of
addSplits()or ofIncrementalSplit'sstopOffsetfield could silently reintroduce the divergence this commit fixes, and CI would not catch it. - Best improvement: add a test mirroring
shouldResolveLatestStopOffsetOnceAtSplitCreationAndReuseAfterRestore's style, but driving it throughaddSplits()instead ofcreateIncrementalSplit(): construct an assigner via the checkpoint constructor withresolvedStopOffset == null(simulating a legacy checkpoint), calladdSplits()with anIncrementalSplitcarrying a non-nullstopOffset, and assert (a) the assigner's subsequently-created splits for another table group reuse that adopted offset, and (b)offsetFactory.latest()is never invoked (verify(offsetFactory, never()).latest()). - Severity: Medium (recovery-path code with no direct test coverage; the underlying scenario itself is narrow, so this is not a merge blocker, but it should be closed before this branch is trusted long-term)
- Raised by another reviewer: No
Issue 2: addSplits() silently picks whichever in-flight split is processed first if multiple already-diverged splits are delivered in the same call
- Location:
seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/IncrementalSplitAssigner.java:175-215 - Problem description:
addSplits()iterates over all incoming splits via.forEach(...); the new guard (resolvedStopOffset == null) means only the first split processed in that call setsresolvedStopOffset. If a job was originally running under an even older, pre-this-PR-series architecture where multiple parallel incremental readers could have already resolved genuinely different stop offsets (which was possible before this PR's single-resolution-point fix existed at all, forincrementalParallelism > 1), and such a job is upgraded straight across a legacy checkpoint with several in-flight splits reported back at once, the assigner arbitrarily adopts one of those divergent values for any newly-created splits belonging to other table groups in the same restore. - Potential risk: low — this doesn't make anything worse than the pre-fix architecture already was for those specific already-in-flight splits (which keep their own baked-in stop offset regardless, since
IncrementalSplitfields arefinal), and it only affects which value newly-created splits for other table groups adopt. It's a genuinely narrow double-upgrade scenario (must have run under the very first, pre-#11884-fix architecture withincrementalParallelism > 1, then jump straight to this version while multiple in-flight tasks fail simultaneously). - Best improvement: not a required fix, but a one-line comment noting the implicit assumption ("if multiple in-flight splits carry different stop offsets, an arbitrary one is adopted") would help a future reader who hits this during a multi-generation upgrade investigation.
- Severity: Low
- Raised by another reviewer: No
2. Code Quality Assessment
2.1 Coding Standards
The new branch and the Javadoc addition both explain the why, consistent with the project's comment-density bar for checkpoint/recovery-adjacent code — the addSplits() comment explicitly states the legacy-checkpoint scenario it exists for, and the threading Javadoc on resolveLatestStopOffsetWithRetry() gives the concrete call path and the reason the retry is safe to block on. No boilerplate/undocumented methods or fields were added.
2.2 Test Coverage and Test Stability
- Unit tests changed in this commit: only a comment update in
HybridSplitAssignerTest.java— no behavioral test change, no stability concerns (noThread.sleep, no nondeterministic assertion, no shared static state touched). - Unit tests NOT added for this commit's actual new logic: see Issue 1 above — the
addSplits()restoration branch has zero direct coverage. - Stability rating for the UT/E2E code touched in this commit: Stable. The only test file touched is a comment-only change; it introduces no new risk. (This rating covers what changed in this commit — it does not retroactively re-certify the E2E test from the prior round, which I already rated Stable in my previous review and which is unchanged here.)
2.3 Documentation Updates
No user-visible behavior changed in this commit, so no docs/en/docs/zh updates are required beyond what was already added in the previous commit (a090452), which I already verified were consistent between the two languages.
3. Architectural Soundness
3.1 Elegance of the Solution
Precise fix. This commit is a small, targeted mirror of an already-established pattern (startupOffset's restoration) rather than a new mechanism — the lowest-risk way to close the gap I identified.
3.2 Maintainability
High — a future maintainer reading addSplits() sees the startupOffset and resolvedStopOffset restoration blocks right next to each other, following the identical if (x == null) { x = ... } shape, so the intent is easy to recognize.
3.3 Extensibility
No new extension points; stays within the existing StopConfig/Offset/IncrementalSplit abstractions.
3.4 Historical-Version Compatibility
Confirmed compatible — see 1.2. The one residual gap (Issue 1, missing test) is a test-coverage concern, not a compatibility break; the runtime behavior itself is correctly scoped to the legacy-restore case and does not touch the serialized checkpoint shape.
4. Issue Summary
| Number | Issue | Location | Severity |
|---|---|---|---|
| 1 | New addSplits() legacy-restore branch (resolvedStopOffset adoption) has no dedicated unit test |
IncrementalSplitAssigner.java:199-212 |
Medium |
| 2 | addSplits() arbitrarily picks the first in-flight split's stop offset if multiple already-diverged splits are delivered in the same call (narrow double-upgrade edge case) |
IncrementalSplitAssigner.java:175-215 |
Low |
5. Merge Recommendation
Conclusion: Ready to merge
This commit does exactly what it says: it closes all three Low-severity follow-ups from my previous approval, and I independently re-verified each one against the actual code rather than trusting the commit message. I did not find any new correctness, compatibility, or side-effect issue introduced by this change — the two items above are a test-coverage gap and a documentation nit on a narrow edge case, not blockers.
1. Blockers — must be fixed
- None.
2. Recommended fixes — non-blocking
- Issue 1: add a unit test exercising
addSplits()'s newresolvedStopOffsetrestoration branch directly (legacy checkpoint + in-flight split), mirroring the existingshouldResolveLatestStopOffsetOnceAtSplitCreationAndReuseAfterRestoretest's style. I'd genuinely like to see this land, even as a fast follow-up, since it's the one piece of this whole fix's checkpoint/recovery surface that isn't independently regression-tested yet. - Issue 2: optional one-line comment documenting the "first-processed split wins" assumption for the extremely narrow double-upgrade case.
CI: the Build check is currently pending on this exact head (bbf1bd5b) as I write this — no result to diagnose yet. This branch is behind_by=75 commits against dev (compare status: diverged), which is queue metadata worth noting, but since there's no failing check yet to evaluate, I'm not recommending a sync at this time; I'll take another look once the run completes if it comes back red.
Overall assessment: this PR has now been through four rounds of review (mine, SEZ9's, and this follow-up) and each round has visibly tightened the design — from reader-side resolution, to enumerator-side resolution at snapshot completion, to the current single-resolution-point-in-createIncrementalSplit design, and now this commit closes the one remaining upgrade-path gap. I'd merge this once CI comes back green, with the missing unit test as a welcome (but non-blocking) follow-up. Also flagging again for @SEZ9: your round-4 CHANGES_REQUESTED was against a396320c, and the current head has since addressed all of those points (I re-verified this independently in my previous review) — a re-review/dismissal on the current head, or a maintainer with write access weighing in, would help move this the rest of the way.
…restore Addresses DanielLeens' round-4 non-blocking follow-ups on PR apache#11885: - New unit test shouldRestoreResolvedStopOffsetFromInFlightSplitOnLegacyCheckpointRestore: a legacy checkpoint (written before the stopOffset field existed) restores the assigner with resolvedStopOffset == null; when an already-assigned incremental split is handed back via addSplits() (reader task failure/retry within the same run), the assigner adopts the split's stop offset and the next split created reuses it instead of re-resolving latest() (no drift, no extra latest() call). Mirrors the existing resolve-once/reuse-after-restore test style. - addSplits(): documented the "first split processed wins" assumption for the narrow case of several already-diverged splits in the same call. Verified: spotless:check, cdc-base unit tests 72/72, git diff --check clean. Co-Authored-By: AtomCode (deepseek-v4-flash) <noreply@atomgit.com>
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks for landing this so quickly, @li3zhi4! I re-reviewed the new commit dc699a34b against my last approval (bbf1bd5b5, 2026-08-27) — this is my fifth pass on this PR. Good news up front: this commit is exactly the non-blocking follow-up I asked for last round (a dedicated regression test for the addSplits() legacy-restore branch, plus the one-line comment on the "first-processed split wins" assumption), the underlying production fix is unchanged, and I found no new issues. I'm keeping this as a consolidated review (not a separate "thanks" comment) per our review process.
What Problem Does This PR Solve?
- User pain point: MySQL-CDC's
stop.mode = "latest", combined with a snapshot-taking startup (initial/earliest), silently dropped every change written to the source table while the snapshot phase was still running, because the stop offset was resolved and frozen too early (at job start / split creation) rather than after the snapshot phase had actually finished. - Fix approach:
IncrementalSplitAssigner.createIncrementalSplit()resolvesstop.mode=latest's stop offset exactly once — the first time an incremental split is created, which is guaranteed to be after the snapshot phase completes — caches it on the assigner and in checkpoint state (IncrementalPhaseState.stopOffset), and retries transient DB failures.addSplits()mirrors the existingstartupOffsetrestoration pattern so a legacy checkpoint (pre-dating thestopOffsetfield) that still carries an in-flight incremental split adopts that split's already-resolved stop offset instead of re-resolving (and drifting) it. - One-sentence summary: this round adds the missing regression test for that
addSplits()restoration branch and a clarifying comment on its one known limitation — no production logic changed.
1. Code Change Review
1.1 Core Logic Analysis
Full diff for this commit (bbf1bd5b5 → dc699a34b, verified via git diff bbf1bd5b5 dc699a34b — only 2 files, +44/-0, no lines removed):
// IncrementalSplitAssigner.java — comment-only addition, no logic change
if (resolvedStopOffset == null
&& context.getSourceConfig() != null
&& context.getSourceConfig().getStopConfig().getStopMode() == StopMode.LATEST
&& incrementalSplit.getStopOffset() != null) {
resolvedStopOffset = incrementalSplit.getStopOffset();
}plus, above it:
// If several splits with already-diverged stop offsets are handed
// back in the same call, the first one processed wins (they can
// only diverge in the same narrow legacy-checkpoint upgrade case).// IncrementalSplitAssignerTest.java — new test
@Test
void shouldRestoreResolvedStopOffsetFromInFlightSplitOnLegacyCheckpointRestore() {
...
IncrementalPhaseState legacyCheckpoint = new IncrementalPhaseState(committedOffset);
IncrementalSplitAssigner<SourceConfig> restoredAssigner =
new IncrementalSplitAssigner<>(context, 1, offsetFactory, legacyCheckpoint);
IncrementalSplit inFlightSplit = new IncrementalSplit(..., committedOffset, resolvedOffset, ...);
restoredAssigner.addSplits(Collections.singletonList(inFlightSplit));
IncrementalSplit nextSplit = restoredAssigner.getNext().get().asIncrementalSplit();
assertSame(resolvedOffset, nextSplit.getStopOffset());
verify(offsetFactory, never()).latest();
}Key findings:
- This is a pure test + comment commit.
git diff bbf1bd5b5 dc699a34btouches onlyIncrementalSplitAssigner.java(comment lines only, theifcondition itself is byte-for-byte unchanged) andIncrementalSplitAssignerTest.java(new test method + 2 new static imports). The production fix I approved last round — single-resolution-point increateIncrementalSplit(), checkpoint-carriedresolvedStopOffset, retry-with-backoff,addSplits()legacy-restore mirroring — is byte-identical to what I already traced end-to-end in my previous two reviews. - I manually verified the new test is non-vacuous (i.e. it actually exercises the
addSplits()branch and would fail without it), rather than taking that on faith:addSplits()does not add the incoming split toassignedSplits/remainingSplits— per its own comment, "we don't store the split, but will re-create incremental split later." So afteraddSplits(),getRemainingTables()still reportsdatabase.schema.tableas unassigned, and the subsequentgetNext()call goes throughcreateIncrementalSplits()→createIncrementalSplit()again for that same table — this is the intended "extract restart state, letgetNext()re-derive a fresh split from it" design, not a re-delivery of the stored split.- Without the
addSplits()branch under test,resolvedStopOffsetwould still benullwhencreateIncrementalSplit()runs, so it would fall intoresolveLatestStopOffsetWithRetry()→StopConfig.getStopOffset(offsetFactory)→offsetFactory.latest()(confirmed viaStopConfig.java:40-43,case LATEST: return offsetFactory.latest();). The test'soffsetFactorymock never stubs.latest(), so it would return Mockito's defaultnullfor an unstubbed object-returning method —assertSame(resolvedOffset, null)andverify(offsetFactory, never()).latest()would both fail. Confirmed: this is a real regression test for the exact branch it targets, not an assertion that trivially passes either way.
- The new comment accurately documents the pre-existing, already-known "first split processed wins" behavior I described as Issue 2 (Low) in my last review — it doesn't change behavior, it just makes an implicit assumption explicit for the next reader, exactly as I suggested.
- I independently re-confirmed
MySqlBinlogFetchTask.javaremains untouched across the entire PR (git diff dev...dc699a34b -- .../MySqlBinlogFetchTask.javais empty) — the fix is, and remains, entirely enumerator-side.checkStopOffset()there still only ever compares againstbinlogSplit.getStopOffset(), the value baked in once by the enumerator; no reader-side re-querying was reintroduced.
1.2 Compatibility Impact
Fully compatible, unchanged from my last two rounds' assessment — this commit changes no API, config option, default, protocol, or serialization shape. IncrementalPhaseState's serialVersionUID is untouched (I checked IncrementalPhaseState.java directly this round — still -6809026812298443356L, still documented as "preserve compatibility with checkpoints written when this state had no fields").
1.3 Performance / Side-Effect Analysis
None — comment and test-only diff, no runtime code path is affected.
1.4 Error Handling and Logging
No new exception paths. No issues found this round.
2. Code Quality Assessment
2.1 Coding Standards
The new test method has a clear, descriptive name and the inline comments explain why each step matters (legacy checkpoint, in-flight split, why latest() must not be called) rather than restating the code. The new production-code comment is likewise a "why", not a "what". No gaps.
2.2 Test Coverage and Test Stability
- This closes the one coverage gap I explicitly flagged as a non-blocking follow-up last round (Issue 1, Medium, from my
bbf1bd5b5review): theaddSplits()legacy-restore branch is now directly regression-tested, closing the exact "a future refactor could silently reintroduce the divergence" risk I called out. - Stability rating: Stable. Pure Mockito-based unit test — no
Thread.sleep, no nondeterministic assertions, no shared static state, no container/timing dependency. This test can't be flaky in the way the E2E suite could be. - No E2E files changed this round, so the E2E readiness-gate design I already rated Stable in my
a090452review is unaffected and unchanged.
2.3 Documentation Updates
No user-visible behavior changed this round; docs/en/docs/zh were already updated and verified consistent in my a090452 review and are untouched here.
3. Architectural Soundness
3.1 Elegance of the Solution
Unchanged from last round: precise fix. This commit specifically improves the fix's test-proof of the checkpoint/recovery surface without touching the mechanism itself.
3.2 Maintainability
Improves it further: the new test documents, in executable form, exactly what the addSplits() restoration branch is supposed to do, which is the best kind of maintainability aid for recovery-path code.
3.3 Extensibility
Unchanged — no new extension points, stays within existing abstractions.
3.4 Historical-Version Compatibility
Unchanged and, if anything, better-evidenced: the legacy-checkpoint-restore scenario (the actual backward-compatibility-sensitive path of this whole PR) now has a dedicated, non-vacuous unit test rather than relying on code review alone.
4. Issue Summary
No new issues found this round.
| # | Issue | Location | Severity |
|---|---|---|---|
| — | None | — | — |
5. Merge Recommendation
Conclusion: Ready to merge
1. Blockers — must be fixed
- None.
2. Recommended fixes — non-blocking
- None remaining from my side; both Low-severity items from my
bbf1bd5b5review (missingaddSplits()test, "first-wins" comment) are now closed by this exact commit.
CI status on the current head (dc699a34b): the fork's Build workflow run for this commit (li3zhi4/seatunnel run 33154652143) shows every job cancelled within ~10-15 seconds of starting (all started_at/completed_at timestamps cluster around 08:15:55–08:16:07 UTC) — this is not a test failure, it looks like the run was cancelled externally (e.g. concurrency-group cancellation or a manual cancel) before any job could produce a real result. The apache-side Build check mirrors this as cancelled. This is inconclusive, not green — @li3zhi4, could you re-trigger CI on this head (a re-run or an empty/rebase push) so we get an actual pass/fail signal before merge?
For context on what to expect once it reruns: the previous head's (bbf1bd5b5) CI run did complete and showed one failure, updated-modules-integration-test-part-1 (8, ubuntu-latest) → PostgresCDCIT.testPostgresCdcSnapshotOnlyAndCommittedOffsetStartupModes. I pulled the actual job log for that run and confirmed it's the identical, already-tracked issue I flagged in my a090452 review: #11847 ("committed-offset restore can silently skip a row committed after savepoint"), fix pending in the still-open #11864. It is a Postgres-CDC, committed-offset/restore issue, unrelated to this PR's connector-cdc-base/MySQL-only diff. I checked and #11864 has not merged yet, so this flake may well resurface on the rerun — if it does, it does not block this PR; no sync-with-dev is needed to clear it, since dev doesn't have the fix yet either.
On @SEZ9's outstanding CHANGES_REQUESTED: still against a396320c7 (round 3). As I noted in my a090452 and bbf1bd5b5 reviews, all 8 of that review's issues were independently re-verified as addressed by a090452 — nothing has changed on that front this round. @SEZ9, a re-review/dismissal on the current head, or a maintainer with write access weighing in, is what's left to move reviewDecision off REVIEW_REQUIRED.
Overall assessment: the core fix has now survived five rounds of adversarial review (mine across multiple architecture iterations, SEZ9's, and this final coverage-closing commit) and I have no remaining correctness, compatibility, or test-coverage concerns. This commit specifically does what it says on the tin. The only thing standing between this and merge is a clean, completed CI run on dc699a34b — please re-trigger it, and once it's green (Postgres flake aside, which is pre-existing and unrelated) I'd consider this fully ready.
DanielLeens
left a comment
There was a problem hiding this comment.
Formalizing the conclusion from my review above as an approval: no blockers, the core fix has been correct and stable since a090452, and this commit closes the last non-blocking follow-up I had open. Approving pending a clean (non-cancelled) CI run on this head.
…hase start
stop.mode=latest previously captured the stop offset when the incremental
split was created (IncrementalSplitAssigner -> offsetFactory.latest()),
which reflects the binlog position at job-start time. For snapshot-taking
startups (initial/earliest) the snapshot phase advances the binlog well
past that stale offset, so the bounded reader terminated immediately on
entering the binlog phase and silently dropped every change written while
the snapshot was running.
Resolve the effective stop offset in MySqlBinlogFetchTask.execute() when
the binlog phase actually starts, and prefer it in checkStopOffset();
specific/timestamp stop modes keep the split's configured offset and
behave exactly as before.
Tests:
- e2e: 5 startup modes x stop.mode=latest combinations
(testMysqlCdc{Initial,Earliest,Latest,Specific,Timestamp}StartupWithLatestStop)
- for initial/earliest, assert the post-snapshot UPDATE (f_varchar=
'latest-stop') is actually synced to the sink (fails on the old stale
stop offset, passes with the fix)
- existing specific-stop tests still pass (no regression)
Co-Authored-By: AtomCode (deepseek-v4-flash) <noreply@atomgit.com>
…pshot completion (enumerator side) Refactor the stop.mode=latest fix from the reader side (per-task re-resolution in MySqlBinlogFetchTask.execute()) to the enumerator side, per review feedback: - IncrementalSplitAssigner resolves the latest stop offset exactly once in completedSnapshotPhase(), when the snapshot phase is confirmed complete, and stores it in IncrementalPhaseState so a checkpoint restore reuses the same value instead of re-resolving (and drifting) it. - createIncrementalSplit() prefers the resolved stop offset; other stop modes keep StopConfig.getStopOffset() (unchanged). - MySqlBinlogFetchTask reverted to dev (no reader-side special-casing). Tests: - IncrementalSplitAssignerTest: new test asserting the stop offset is resolved once at snapshot completion and reused after restore (no drift). - E2E: keep the 5 startup-mode x latest-stop matrix; bulk-insert 200 rows so the snapshot phase of initial/earliest startups is measurably non-trivial, closing the readiness-signal vs snapshot-completion race that failed in CI. Co-Authored-By: AtomCode (deepseek-v4-flash) <noreply@atomgit.com>
… E2E snapshot race Replace the probabilistic RUNNING-then-UPDATE timing margin with a structural readiness gate, per review feedback on PR apache#11885: - initial: wait until the first bulk row (id=1) is visible in the sink before issuing the UPDATE. With snapshot.split.size=20 the 200-row table is read in 10 snapshot splits, so this signal can only fire while the snapshot is still reading the remaining splits — the UPDATE is guaranteed to land inside the snapshot window and be captured by the binlog phase (deterministic, no timing margin). - earliest: remove the post-snapshot UPDATE assertion. There is no snapshot phase for earliest (incremental split's completedSnapshotSplitInfos is empty, binlog replay starts from the earliest position), so whether the UPDATE is captured depends on enumerator stop-offset resolution timing versus the UPDATE — not a deterministic contract. The test still asserts RUNNING and FINISHED. - latest/specific/timestamp: unchanged (no snapshot window; UPDATE not read is expected, only RUNNING/FINISHED asserted). E2E verified locally: initial+earliest 2/2, latest+specific+timestamp 3/3, existing specific-stop regression 2/2 (7/7 total). Co-Authored-By: AtomCode (deepseek-v4-flash) <noreply@atomgit.com>
…ix (PR apache#11885) Addresses every finding from the round-3 (DanielLeens) and round-4 (SEZ9) reviews: - NPE in completedSnapshotPhase: the stop.mode=latest resolution moved out of completedSnapshotPhase entirely (into createIncrementalSplit), so the method no longer dereferences context.getSourceConfig(); HybridSplitAssignerTest now supplies a mocked SourceConfig (StopMode.NEVER) to keep the test's intent explicit (DanielLeens round-3 Issue 1, High). - Single authoritative stop-offset resolution point (SEZ9 Issue 2, confirmed real by DanielLeens): createIncrementalSplit resolves latest() exactly once when resolvedStopOffset == null and reuses it for every split and the checkpoint. The split handed to the reader and the checkpointed value can no longer diverge, so a restore cannot silently move the stop boundary. - Retry/backoff around the latest() resolution (SEZ9 Issue 5): a transient DB failure at the snapshot-to-incremental transition is retried 3x instead of failing the whole job (mirrors the connection-factory retry pattern). - Serialization round-trip unit test (SEZ9 Issue 6): IncrementalPhaseStateTest proves stopOffset survives a real Java serialization round-trip and that a legacy single-arg state deserializes with stopOffset == null (unchanged serialVersionUID, plain Java field evolution - there is no hand-written serializer in connector-cdc-base, per DanielLeens' verification). - Deterministic e2e readiness for initial (SEZ9 Issue 3): 2000-row bulk (snapshot.split.size=20 -> 100 splits) so the sink-visibility gate fires with ~99 splits unread, plus a defensive assertion that the last-chunk row is not yet in the sink (fails loudly with "snapshot finished too early" instead of a misleading data-loss message). Row-lock stalls are not usable: the snapshot reader issues a plain MVCC SELECT, so FOR UPDATE does not block it. - Docs (SEZ9 Issue 4): stop.mode=latest snapshot-window semantics documented in MySQL-CDC.md (en/zh). - PR description aligned with the enumerator-side implementation (SEZ9 Issues 7/8). Verified: spotless:check, cdc-base unit tests 71/71, e2e 7/7 (initial+earliest 2/2, latest+specific+timestamp 3/3, specific regression 2/2), git diff --check clean. Co-Authored-By: AtomCode (deepseek-v4-flash) <noreply@atomgit.com>
…the latest-stop fix Three Low-severity items from the round-4 approval review: - addSplits() now mirrors the startupOffset restoration pattern for the resolved latest stop offset: a checkpoint written before the stopOffset field existed carries none, so on restore the re-created incremental split still holds the previously resolved stop offset - reuse it instead of re-resolving (and drifting) at split creation (legacy-checkpoint + incrementalParallelism > 1 upgrade case). - HybridSplitAssignerTest: tightened the mock-SourceConfig comment - the stop.mode=latest resolution lives in createIncrementalSplit, not completedSnapshotPhase, so the comment no longer overstates the reason. - resolveLatestStopOffsetWithRetry: documented the threading model - it runs on the job's own per-job split-enumerator coordinator thread (not a shared cross-job pool), and the bounded backoff (300ms + 600ms) matches the connection-factory retry pattern. Verified: spotless:check, cdc-base unit tests 71/71, git diff --check clean. Co-Authored-By: AtomCode (deepseek-v4-flash) <noreply@atomgit.com>
…restore Addresses DanielLeens' round-4 non-blocking follow-ups on PR apache#11885: - New unit test shouldRestoreResolvedStopOffsetFromInFlightSplitOnLegacyCheckpointRestore: a legacy checkpoint (written before the stopOffset field existed) restores the assigner with resolvedStopOffset == null; when an already-assigned incremental split is handed back via addSplits() (reader task failure/retry within the same run), the assigner adopts the split's stop offset and the next split created reuses it instead of re-resolving latest() (no drift, no extra latest() call). Mirrors the existing resolve-once/reuse-after-restore test style. - addSplits(): documented the "first split processed wins" assumption for the narrow case of several already-diverged splits in the same call. Verified: spotless:check, cdc-base unit tests 72/72, git diff --check clean. Co-Authored-By: AtomCode (deepseek-v4-flash) <noreply@atomgit.com>
dc699a3 to
0642fc3
Compare
…olution Restore the missing closing brace of shouldReassignTablesRestoredFromCheckpointWithTheirWatermark, restore the @test annotation on shouldResolveLatestStopOffsetOnceAtSplitCreationAndReuseAfterRestore, and drop a stray pasted commit-message line at the seam. No functional changes.
|
@SEZ9 Reposting the portion of @DanielLeens' review above that gets truncated in some views — the findings mapping it contains, verbatim:
|
|
@SEZ9 @li3zhi4 confirmed — I re-fetched my 2026-09-08 review body directly via the API (not the rendered view) and it is complete end to end, including the @SEZ9, to directly restate what you flagged as still needing a pointer, now confirmed against the actual diff at
No new commit since I last reviewed — the head is still |
|
@DanielLeens thanks for re-fetching the review body and restating the F1–F8 mapping against One thing before I mark items closed: your comment describes what the diff contains, but I still need to verify each point against the actual changes at
Once I can see those hunks I'm happy to close everything out — nothing in your explanation looks wrong to me, I just want the closure to rest on the diff rather than the summary. |
|
@SEZ9 fair ask — here are the concrete hunks at F1/F6 —
F2 — F5 — F3 — F4/F7/F8 — All of the above is me re-reading the actual file contents at |
|
@SEZ9 Here are the concrete locations at |
|
@li3zhi4 Thanks for independently pulling the same hunks — your line citations for F1/F6, F2, F5, F3, and F4/F7/F8 match what I verified in my own comment above at every location I checked: same files, the same @SEZ9 between my comment and li3zhi4's, every hunk you asked for is now pointed at directly rather than summarized. Let us know if anything still looks off once you've checked them against the diff yourself — otherwise this looks ready to close out on your side. |
|
Thanks @li3zhi4 — the pointers at On F1/F6: On the rest, I see the thread already points at the |
|
@SEZ9 Checked the stored comment body directly via the API (not the rendered view) — @li3zhi4's comment at On the rest: the F2/F5 guard at |
…l-cdc-stop-mode-latest
|
Gentle close-out nudge \u2014 @SEZ9 you mentioned "Once I can see those hunks I'm happy to close everything out." The concrete locations at |
|
@li3zhi4 thanks for the nudge, and apologies for the delay on my side. The location list you posted against Since the head has moved to Nothing further needed from you at this point; I'll post my final confirmation here once I've been through the |
|
@SEZ9 @nzw921rx — synced the branch with current dev There is currently no new fork Build run/check suite for this SHA, despite the recorded push, Actions enabled, and workflows matching upstream. Upstream therefore reports Please complete the promised final review against the synced head and give/update a normal approving review when satisfied. dev's merge queue requires a current valid approval and a successful Build, so a comment-only sign-off does not by itself remove the merge gate. My account cannot issue formal reviewer requests through the API. |
DanielLeens
left a comment
There was a problem hiding this comment.
What Problem Does This PR Solve?
Thanks for keeping this branch current, @li3zhi4. Since my last review (2026-09-08, head befad345c1) the head moved only through two merges of dev (b0ab23fb03 on 2026-09-29 and 99d1db7934 on 2026-10-09). I re-reviewed the latest head 99d1db7934ce from the top, including CI and the merge state.
- User pain point: MySQL CDC with
startup.mode = initial/earliestandstop.mode = latestfroze the stop offset when the incremental split was created, before the snapshot finished. By the time the binlog phase started the stop offset was already behind the current position, so the job ended immediately and every change made during the snapshot was silently dropped. - Fix approach:
IncrementalSplitAssigner.createIncrementalSplit()resolves thelateststop offset exactly once (guarded byresolvedStopOffset == null) the first time an incremental split is created, which only happens after the snapshot assigner reports completion. The value is cached, reused for later splits, carried inIncrementalPhaseState, and restored throughaddSplits(), with a bounded retry for the offset lookup. - One-sentence summary: Resolve the "latest" stop offset at the post-snapshot boundary on the enumerator side so a bounded CDC job captures everything up to the end of the snapshot.
1. Code Change Review
1.1 Core Logic Analysis
I compared the PR's own added and removed lines at befad345c1 (the head I last reviewed) against the current head, each taken against its merge base with dev: 658 changed lines on both sides and zero differences. So the author's work, including the production change in IncrementalSplitAssigner / IncrementalPhaseState, the tests, the E2E and the docs, is line-for-line what I verified before. I also checked that dev did not change any of the PR's 11 files after the current merge base, so the merges did not create a semantic conflict with the assigner or its tests.
Runtime path, unchanged: HybridSplitAssigner reports snapshot completion -> IncrementalSplitAssigner.createIncrementalSplit() -> one-time resolveLatestStopOffsetWithRetry() -> cached resolvedStopOffset -> IncrementalSplit.stopOffset -> binlog reader checkStopOffset(). For restore, IncrementalPhaseState carries the resolved offset through the engine's default Java serialization, and addSplits() adopts an in-flight split's offset for legacy checkpoints.
Key findings
- The normal path for
startup.mode = initialwithstop.mode = latestreaches the changed logic, so this is a direct fix and not only a recovery-path fix. - The fix stays enumerator-side; the reader (
MySqlBinlogFetchTask) is untouched. - No new issue found, and nothing here is a carryover from an earlier round.
1.2 Compatibility Impact
Fully compatible. No option or default changes; stop.mode = latest now behaves as documented for snapshot startups. A checkpoint without the new field deserializes with stopOffset = null and re-resolves, which IncrementalPhaseStateTest pins.
1.3 Performance / Side-Effect Analysis
One extra offset lookup per job (at most 3 attempts with 300ms/600ms backoff) on the enumerator thread. No new memory, lock or per-record cost.
1.4 Error Handling and Logging
Lookup failures are retried and then surfaced with context instead of being swallowed.
2. Code Quality Assessment
2.1 Coding Standards
Good; no changes since my last review.
2.2 Test Coverage and Test Stability
Unit tests cover single resolution, reuse after restore and legacy-state defaults; MysqlCDCStopModeSpecificIT uses a structural readiness gate (row 1 reaches the sink while row 2000 must not yet) rather than sleeps. I reviewed them statically and did not run them. Stability rating: Stable.
2.3 Documentation Updates
docs/en and docs/zh MySQL-CDC pages are both updated and consistent.
3. Architectural Soundness
Precise fix at the one point where "post-snapshot" holds by construction; maintainable, extensible to every connector-cdc-base connector, and compatible with historical checkpoints.
4. Issue Summary
No issues found on this head.
5. Merge Recommendation
Conclusion: Ready to merge
- Blockers - must be fixed: No source-side blockers. The two remaining gates are CI and the required re-approval (below).
- Recommended fixes - non-blocking: None.
CI status: no Build has run on this head. The apache-side Build check is ACTION_REQUIRED with "Unable to detect the workflow run for testing the changes in your PR". I looked at the fork: there is no workflow run at all for 99d1db7934 (the last Build run on this branch was for b0ab23fb03 on 2026-09-29, and the fork's other non-scheduled runs are for different branches). So this is not a test failure; the push of the merge commit simply did not start a fork run. The lowest-cost next step is to create and push an empty commit to the branch (for example git commit --allow-empty -m "Trigger CI" followed by a normal push), which is the first remedy the check message itself suggests, and then confirm a Build run appears in your fork's Actions tab. A further sync is not needed for this; the branch already contains the upstream CI fixes you mentioned (#12639, #12297, #12394). The earlier failures on b0ab23fb03 and befad345c1 were not caused by this diff, and the new head should be judged on a fresh run.
Merge state: the branch is behind dev (behind_by=25, status diverged) with no conflicts (mergeable=true). mergeStateStatus=BLOCKED and reviewDecision=REVIEW_REQUIRED come from the missing Build and from @SEZ9's formal CHANGES_REQUESTED (round 3, head a396320c73) still being open. I verified all eight of those items as addressed in my 2026-09-08 review, and the code is unchanged since, so my technical conclusion is that no source blocker remains. I only have read-level review controls here, so a maintainer with write access will need to submit the final approval or dismissal.
Response to existing reviews: @SEZ9 said on 2026-09-30 that he would do a final read of the current diff before signing off; since the author's code is identical to befad345c1, my earlier per-item verification still applies, and I defer to him for the formal sign-off.
Thanks again for the persistence and the careful work on this one.
|
Thanks for keeping the branch current. Since
Once I have those pointers I'll do a focused re-check of just these items. |
DanielLeens
left a comment
There was a problem hiding this comment.
What Problem Does This PR Solve?
Thanks again for keeping this branch current, @li3zhi4. Since my last review (2026-10-10, head 99d1db7934) the head moved through three more dev merges (7a0ed0bb6a, b1df909bd5, and now 7f17332b7a). I re-read the whole diff of the latest head 7f17332b7aa8 from the top, and I also looked at @SEZ9's request of today for pointers, which I answer below so the focused re-check can be quick.
- User pain point: MySQL CDC with
startup.mode = initial/earliestandstop.mode = latestfroze the stop offset when the incremental split was created, before the snapshot finished. Changes made while the snapshot was running ended up behind the stop offset and were silently dropped. - Fix approach:
IncrementalSplitAssigner.createIncrementalSplit()resolves thelateststop offset exactly once, when the first incremental split is created after the snapshot assigner reports completion; the value is cached inresolvedStopOffset, checkpointed throughIncrementalPhaseState, restored through the constructor andaddSplits(), with a bounded retry on the lookup. - One-sentence summary: Resolve the "latest" stop offset at the post-snapshot boundary on the enumerator side so a bounded CDC job captures everything up to the end of the snapshot.
1. Code Change Review
1.1 Core Logic Analysis
I compared the PR's own added/removed lines against its merge base with dev for the previously reviewed head 99d1db7934 and for the current head 7f17332b7a: both are 650 additions / 8 deletions over the same 11 files, and the hash of the changed lines is identical. So the author's work is line-for-line what I verified before; the three newer commits are only dev merges. The branch is now fully up to date with dev (behind_by=0, ahead_by=12, mergeable=MERGEABLE), so there is no semantic conflict with dev either.
Runtime path, unchanged:
HybridSplitAssigner (snapshot reports completion)
-> IncrementalSplitAssigner.createIncrementalSplit() (resolve once, resolvedStopOffset == null guard, :329-:343)
-> resolveLatestStopOffsetWithRetry() (:389, 3 attempts, 300ms/600ms backoff)
-> IncrementalSplit.stopOffset -> reader checkStopOffset()
snapshotState() -> IncrementalPhaseState(startupOffset, resolvedStopOffset) (:227)
restore: constructor adopts checkpointState.getStopOffset() (:124); addSplits() adopts an in-flight split's offset for legacy checkpoints (:210-:215)
Pointers for @SEZ9's five items (all at head 7f17332b7a):
- F1/F6 checkpoint round-trip: persisted by
IncrementalPhaseState.stopOffset(IncrementalPhaseState.java:39,49-51) and written inIncrementalSplitAssigner.snapshotState()(:227); restored at:124; legacy fallback inaddSplits()(:210-:215, only forstop.mode=LATESTand a non-null split offset).IncrementalPhaseStateTesthasshouldPreserveStopOffsetThroughJavaSerializationRoundTrip(:35) andshouldDefaultStopOffsetToNullOnLegacySerializedState(:50), which go through the real Java serialization path (the connector-cdc-base enumerator state is serialized by the engine's default serializer), not just object construction.IncrementalSplitAssignerTestaddsshouldRestoreResolvedStopOffsetFromInFlightSplitOnLegacyCheckpointRestore(:200). - F2 stop-boundary consistency: the split offset and the checkpointed value come from the same field,
resolvedStopOffset, assigned once under the== nullguard (:329) and read for every later split (:341-:343), so they cannot diverge;shouldResolveLatestStopOffsetOnceAtSplitCreationAndReuseAfterRestore(IncrementalSplitAssignerTest:158) covers single resolution and reuse after restore. - F3 E2E readiness gate:
MysqlCDCStopModeSpecificIT.runLatestStopStartupMode(:340) inserts 2000 rows forinitial(100 splits atsnapshot.split.size=20), waits for the job to beRUNNINGand for row id=1 to reach the sink (:398-:411), and then asserts that the last-chunk row id=2000 is still absent from the sink (:420-:422), failing loudly if the snapshot already finished. Only then is theUPDATEof id=21 issued (:437-:440) and asserted to reach the sink (:444-:449) before the job must finish with exit code 0. So the gate is not id=1 alone: the id=2000 check proves the snapshot is still in progress. The onlyThread.sleepin that file (:232) is pre-existing and not part of this diff. - F5 retry:
resolveLatestStopOffsetWithRetry()atIncrementalSplitAssigner.java:389;maxRetries = 3, backoff300ms * attempt(at most 300ms + 600ms), interrupt restores the flag, and the final failure is wrapped in aSeaTunnelExceptionwith the attempt count. - F4/F7/F8 docs:
docs/en/connectors/source/MySQL-CDC.mdanddocs/zh/connectors/source/MySQL-CDC.mdboth describe thestop.mode = latestpost-snapshot semantics in the option table and in a dedicated example. For the PR description, @li3zhi4 should confirm it reflects the enumerator-side implementation; I cannot see edits to the description in the commit history, so that one is for the author to confirm.
Key findings
- The normal path for
startup.mode = initialwithstop.mode = latestreaches the changed logic, so this is a direct fix and not only a recovery-path fix. - The reader (
MySqlBinlogFetchTask) is untouched. - No new issue found, and nothing here is a carryover from an earlier round.
1.2 Compatibility Impact
Fully compatible. No option or default changes. A checkpoint without the new field deserializes with stopOffset = null and re-resolves; the single-argument IncrementalPhaseState(Offset) constructor is kept.
1.3 Performance / Side-Effect Analysis
One extra offset lookup per job (bounded retries) on the enumerator thread. No new memory, lock or per-record cost.
1.4 Error Handling and Logging
Lookup failures are retried, logged with context, and then surfaced as a SeaTunnelException; nothing is swallowed.
2. Code Quality Assessment
2.1 Coding Standards
Good. The new field, the new state field and the retry method carry comments explaining why (single resolution, restore, threading).
2.2 Test Coverage and Test Stability
Unit tests cover single resolution, reuse after restore, legacy fallback and the serialization round trip; the E2E uses a structural readiness gate rather than sleeps. I reviewed them statically and did not run them. Stability rating: Stable.
2.3 Documentation Updates
docs/en and docs/zh are both updated and consistent.
3. Architectural Soundness
The fix is at the one point where "post-snapshot" holds by construction, it is generic for every connector-cdc-base connector, and it stays compatible with historical checkpoints.
4. Issue Summary
No issues found on this head.
5. Merge Recommendation
Conclusion: Ready to merge
- Blockers - must be fixed: No source-side blockers. Remaining gates are CI and the formal re-approval.
- Recommended fixes - non-blocking: None.
CI status: pending, not failing. At the time of this review the fork's Build run for this exact head (https://github.com/li3zhi4/seatunnel/actions/runs/38382236864) is queued, and the apache-side checks Notify test workflow and labeler are queued as well. This is a good change from the previous head, where no fork run was created at all. No action is needed from you beyond letting this run finish; if a lane fails I will check whether it relates to the diff.
Merge state: mergeStateStatus=BLOCKED and reviewDecision=REVIEW_REQUIRED come from the pending Build and the open formal CHANGES_REQUESTED from @SEZ9 (round 3, head a396320c73). I only have read-level review controls, so the formal approval or dismissal must come from a maintainer with write access. I defer to @SEZ9 for the focused re-check using the pointers above.
Thanks for the persistence and the careful work on this one!
|
Thanks @SEZ9 \u2014 I rechecked the exact current head |
|
Thanks @li3zhi4 for the point-by-point mapping against I'm not marking anything resolved from the mapping alone; I'll verify each item against the changed files at
Once I've checked those, I'll update the findings accordingly. |
|
Thanks @SEZ9 \u2014 I checked the requested interactions on current head |
|
@SEZ9 @nzw921rx — CI on current head The source-level pointer/evidence replies above remain applicable to this exact SHA. Please complete the final review and update/request the normal write-enabled approving review once satisfied; REVIEW_REQUIRED is the remaining merge gate. A green Build is not by itself a formal approval. |
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks @li3zhi4 and @SEZ9 for the careful evidence round. My last review of head 7f17332b7a concluded "Ready to merge" with no source-side blockers, and the only remaining gates were CI and the formal approval. The required Build for this exact head is now SUCCESS, so I am changing my conclusion to approve. The reviewed diff is unchanged since then (the later commits are dev merges), and nothing I raised earlier remains open. This is a static review of the diff plus the CI results; I did not run the PR locally.
Please keep waiting for @SEZ9's own verification of F1-F8 before a committer merges.
davidzollo
left a comment
There was a problem hiding this comment.
Thank you @li3zhi4 for this contribution, and for resolving the stop.mode=latest stop offset at the binlog phase. Thank you for your patience and your detailed replies during the review rounds.
CI is green on the current head and the code-side review has no remaining blockers, so I am approving. Really appreciate the time and care you put into this PR - contributions like this make SeaTunnel better for everyone. Looking forward to more from you!
Purpose of this pull request
Fixes issue #11884: MySQL CDC
stop.mode = "latest"silently drops every change written while the snapshot phase is running.Root cause:
IncrementalSplitAssignerresolves thestop.mode = lateststop offset at incremental-split creation viaoffsetFactory.latest(), freezing the binlog position at that moment intoIncrementalSplit.stopOffset(afinalfield). For snapshot-taking startups (initial/earliest) the snapshot phase advances the binlog past that stale offset, so when the binlog phase startscheckStopOffset()immediately seescurrentBinlogOffset.isAtOrAfter(stopOffset) == trueand the job finishes without reading any post-snapshot change.Fix (enumerator side):
IncrementalSplitAssigner.createIncrementalSplit()resolves thelateststop offset exactly once — at the first incremental split creation, guarded byresolvedStopOffset == null— and reuses the same value for every subsequent split and for the checkpoint. BecauseHybridSplitAssigneronly enters incremental allocation after the snapshot assigner reports completion, this single resolution point is necessarily post-snapshot (never stale), and storing it inIncrementalPhaseState.stopOffset(plain Java serialization,serialVersionUIDunchanged) makes a checkpoint restore reuse the same value instead of re-resolving and drifting the stop boundary. The transient-DB-failure case is handled with a short retry/backoff.specific/timestamp/neverstop modes keep the split's configured offset — behavior unchanged. The fix lives inconnector-cdc-base, so it applies to every CDC connector built on it (MySQL, Oracle, SQL Server, PostgreSQL, ...).Does this PR introduce any user-facing change?
Yes:
stop.mode = "latest"combined with a snapshot-taking startup now terminates at the binlog position resolved when the snapshot phase completes, so changes produced while the snapshot ran are no longer lost (previously the stale split-creation offset stopped the job immediately past it). For non-snapshot startups (latest/specific/timestamp) behavior is unchanged. Documented indocs/en|zh/connectors/source/MySQL-CDC.md.How was this patch tested?
IncrementalSplitAssignerTest(resolve-once at split creation + reuse after restore),IncrementalPhaseStateTest(Java serialization round-trip keepsstopOffset; legacy single-arg state deserializes withstopOffset = null),HybridSplitAssignerTest(no NPE on the pre-existing test with a mockedSourceConfig).initial/earliest/latest/specific/timestamp) ×stop.mode = latest(testMysqlCdc{Initial,Earliest,Latest,Specific,Timestamp}StartupWithLatestStop).initial, the test uses a sink-visibility readiness gate (first bulk row visible) over a 2000-row / 100-split snapshot so theUPDATEissued afterwards is guaranteed to land inside the snapshot window, then asserts the post-snapshot change (f_varchar='latest-stop') is synced — this assertion fails on the old stale stop offset and passes with the fix.specific-stop tests still pass (no regression).spotless:check✅, compile ✅, unit tests ✅, e2e 7/7 ✅ (local).Check list
mvn spotless:checkpassesstop.mode = latestsnapshot-window semantics in MySQL-CDC.md en/zh)