LiuHao0606 opened a new issue, #13340:
URL: https://github.com/apache/seatunnel/issues/13340
### Search before asking
- [x] I had searched in the issues and found no similar issue.
### What happened
A long-running MySQL CDC job (single large table, tens of millions of rows,
snapshot phase ~15 hours) fails with a NullPointerException at the
snapshot-to-incremental transition. The job runs fine for many hours, completes
hundreds of successful checkpoints, and then fails. Both a plain restart and a
restore from the latest successful checkpoint reproduce the exact same failure
at the same split (the last snapshot split of the table, where splitEnd = null).
The exception visible on the SourceTask node is a Hazelcast-wrapped
SourceFlowLifeCycle.requestSplit error. The real NPE is only visible in the log
of the node hosting the SplitEnumerator (in Zeta cluster mode these can be on
different nodes):
java.lang.NullPointerException
at
org.apache.seatunnel.connectors.cdc.base.source.enumerator.IncrementalSplitAssigner.createIncrementalSplit(IncrementalSplitAssigner.java:300)
at
org.apache.seatunnel.connectors.cdc.base.source.enumerator.IncrementalSplitAssigner.createIncrementalSplits(...)
at
org.apache.seatunnel.connectors.cdc.base.source.enumerator.IncrementalSplitAssigner.getNext(...)
at
org.apache.seatunnel.connectors.cdc.base.source.enumerator.HybridSplitAssigner.getNext(...)
at
org.apache.seatunnel.connectors.cdc.base.source.enumerator.IncrementalSourceEnumerator.assignSplits(...)
at
org.apache.seatunnel.connectors.cdc.base.source.enumerator.IncrementalSourceEnumerator.handleSplitRequest(...)
...
The job runs with exactly-once = false.
### What you expected to happen
Restoring from a successful checkpoint (or a restart) should resume
consumption without a NPE.
### Root cause analysis
IncrementalSplitAssigner.java:295-301 (3.1.0):
SnapshotSplitWatermark splitWatermark =
splitCompletedOffsets.get(split.splitId());
Offset splitOffset = sourceConfig.isExactlyOnce()
? splitWatermark.getHighWatermark()
: splitWatermark.getLowWatermark(); // line 300 - NPE when
splitWatermark == null
splitCompletedOffsets is populated by onCompletedSplits(). When
createIncrementalSplit is called before that map is filled for a given split,
splitWatermark is null.
The behavior change is in IncrementalSourceEnumerator.addSplitsBack():
// 3.0.0 - safe
public void addSplitsBack(List<SourceSplitBase> splits, int subtaskId) {
LOG.debug(...);
splitAssigner.addSplits(splits);
}
// 3.1.0 - triggers the NPE
public synchronized void addSplitsBack(...) {
splitAssigner.addSplits(splits);
if (running) {
assignSplits(); // NEW - immediately allocates splits
}
}
Chain on restore:
1. Engine calls addSplitsBack to return splits; 3.1.0 immediately calls
assignSplits()
2. assignSplits() -> getNext() -> createIncrementalSplit()
3. At this moment splitCompletedOffsets has not been filled yet, so
splitWatermark = null
4. splitWatermark.getLowWatermark() -> NPE
3.0.0 only enqueues the splits and waits for the normal scheduling cycle, by
which time the watermark is ready, hence no NPE.
This new if (running) assignSplits() was likely introduced to fix #11676
(restored splits not assigned, job appears RUNNING but produces no data), but
it introduces this NPE.
I verified the same NPE line exists in v3.0.0 (line 261), 3.1.0 (line 300)
and the current dev branch; the line itself is unchanged, only the upstream
call timing differs. So upgrading to 3.1.0 (currently the latest release) does
not fix it.
### Suggested fix
Add a null guard for splitWatermark in createIncrementalSplit (e.g. skip the
split or fall back to the snapshot split's low watermark when absent), or defer
assignSplits() in addSplitsBack until the watermarks are ready.
### Steps to reproduce
1. MySQL CDC source with a large table (tens of millions of rows),
exactly-once = false.
2. Let the snapshot phase run for many hours and accumulate checkpoints.
3. Trigger a checkpoint restore / failover near the end of the snapshot
phase, or restore from the last successful checkpoint.
4. Observe the NPE at IncrementalSplitAssigner.createIncrementalSplit.
### Environment
- SeaTunnel 3.1.0 (Zeta, 2-node hybrid cluster)
- Java 11.0.23
- Sink: Paimon (likely irrelevant; the failure is in the CDC source
enumerator)
### Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]