Repository navigation
Description
Search before asking
- I had searched in the issues and found no similar issues.
What happened
In the SeaTunnel Zeta engine (dev at 39c74ce48b0), whenever a submitted job reaches a terminal state before its SubPlan pipelines ever start running — specifically:
- A job waiting in
pendingJobQueueunderScheduleStrategy.WAITis canceled viacancelJob(jobId), or - A job fails immediately with
NoEnoughResourceExceptionunderScheduleStrategy.REJECTbecausepreApplyResources()cannot obtain enough slots
its per-pipeline checkpoint ID counter entries initialized during JobMaster.init() are never removed from checkpointCounterStore (backed by Hazelcast IMap engine_checkpoint-id-map / Constant.IMAP_CHECKPOINT_ID).
Because engine_checkpoint-id-map has no TTL or eviction policy, every canceled PENDING job and every REJECT-failed job leaks one entry per pipeline permanently in cluster memory (and in IMap external storage when persistence is enabled).
Root Cause Analysis
- Counter entries are eagerly created during
JobMaster.init(), before scheduling:CoordinatorService.submitJob()callsjobMaster.init(...)->initCheckPointManager(...)->new CheckpointManager(...).- In
CheckpointManager(seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/checkpoint/CheckpointManager.java:161-167), every pipeline constructs aStateStoreCheckpointIDCounterand immediately invokesidCounter.start(), callingcheckpointCounterStore.initializeIfAbsent(key, INITIAL_CHECKPOINT_ID).
- Counter removal is only wired to
SubPlantermination:StateStoreCheckpointIDCounter.shutdown(PipelineStatus)(which callscheckpointCounterStore.remove(key)whenpipelineStatus.isEndState()) is only invoked viaCheckpointManager.listenPipeline(int pipelineId, PipelineStatus pipelineStatus).CheckpointManager.listenPipeline(...)is only called fromSubPlan.notifyCheckpointManagerPipelineEnd(PipelineStatus)(SubPlan.java:375-383), which only executes if theSubPlanstate machine actually ran and reached a terminal state.
- Pre-execution termination paths bypass
SubPlancompletely andJobMaster.cleanJob()does not clean up counters:- PENDING cancel:
CoordinatorService.cancelJob(jobId)removes the job frompendingJobQueueand callsrunningJobMaster.cancelJob()->PhysicalPlan.cancelJob(), which directly setsJobStatus.CANCELEDand callscompleteJobEndFuture(...)->JobMaster.cleanJob(). - REJECT insufficient resources:
CoordinatorService(aroundNoEnoughResourceException, lines 536–544) directly setsJobStatus.FAILEDand callscompleteJobEndFuture(...)->JobMaster.cleanJob(). JobMaster.cleanJob()(JobMaster.java:1041-1046) callscheckpointManager.clearCheckpointIfNeed(physicalPlan.getJobStatus())(which only deletes external checkpoint storage) andscheduleRemoveJobStateMaps()(which cleans uprunningJobStateIMap,runningJobStateTimestampsIMap,ownedSlotProfilesIMap,runningJobInfoIMap,metricsImap), but never removes the job's entries fromcheckpointCounterStore/IMAP_CHECKPOINT_ID.
- PENDING cancel:
Expected Behavior
When any job reaches a terminal state (FINISHED, CANCELED, FAILED, SAVEPOINT_DONE), all of its per-pipeline checkpoint ID counter entries in checkpointCounterStore (engine_checkpoint-id-map) should be cleanly removed — regardless of whether the job's SubPlans ever started running.
How to Reproduce
Scenario A: Canceling a PENDING job under ScheduleStrategy.WAIT
- Start a single-node embedded Zeta cluster with fixed slots (
dynamic-slot: false,slot-num: 5) andschedule-strategy: WAIT. - Submit a normal batch job (
normalJobId) as a control and wait until it reachesFINISHED.- Observe
checkpointCounterStore/IMap<String, Long>(Constant.IMAP_CHECKPOINT_ID) for keyconvertLongIntToBase64(normalJobId, 1)-> not present (false, properly cleaned up bySubPlan).
- Observe
- Submit a streaming job (
holderJobId) consuming 2 of the 5 slots and wait until it isRUNNING. - Submit a 5-slot batch job (
pendingJobId, e.g.,batch_slot_not_enough.conf) so it entersJobStatus.PENDINGinpendingJobQueue.- Observe
IMAP_CHECKPOINT_IDcontains keyconvertLongIntToBase64(pendingJobId, 1)with value1L.
- Observe
- Call
client.cancelJob(pendingJobId)and wait untilcoordinator.getJobStatus(pendingJobId) == JobStatus.CANCELED. Also cancelholderJobIduntilCANCELED. - Inspect
IMAP_CHECKPOINT_ID/checkpointCounterStore:holderJobIdkey is removed (false).pendingJobIdkey is still present with value1L(mapSize == 1), leaked permanently.
Scenario B: Job rejected under ScheduleStrategy.REJECT
- Start a single-node embedded Zeta cluster with fixed slots (
dynamic-slot: false,slot-num: 2) andschedule-strategy: REJECT. - Submit a 5-slot batch job (
rejectedJobId, e.g.,batch_slot_not_enough.conf). - Wait for the job to terminate (
JobStatus.FAILEDwithNoEnoughResourceException). - Inspect
IMAP_CHECKPOINT_ID/checkpointCounterStore:rejectedJobIdkeyconvertLongIntToBase64(rejectedJobId, 1)is still present with value1L(mapSize == 1), leaked permanently.
Suggested Fix Direction
- In
CheckpointManager, provide a job-level terminal cleanup method (or extendclearCheckpointIfNeed(JobStatus)/ addshutdownAllCheckpointIdCounters(JobStatus)) that iterates all coordinators incoordinatorMapwhenjobStatus.isEndState()and invokescheckpointIdCounter.shutdown(...)(mapping terminalJobStatusto a terminalPipelineStatus) so every pipeline counter key is idempotently removed duringJobMaster.cleanJob(). - Also verify partial-initialization failure handling in
JobMaster.init()/CheckpointManagerconstructor so partially initialized counters are cleaned up ifinit()throws. - Add regression unit/E2E tests verifying zero leftover keys in
checkpointCounterStore(IMAP_CHECKPOINT_ID) after bothPENDINGcancellation andREJECTresource-exhaustion failure.
Call for Contributors
This is a well-scoped, self-contained Zeta engine bug with clear reproduction steps and low blast radius. Community contributors are very welcome to pick this up and submit a PR! Feel free to comment below if you'd like to claim it or discuss the cleanup design.
SeaTunnel Version
dev (39c74ce48b0)
Are you willing to submit a PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
hutiefang76 commentedon Nov 26, 2026
Yes, I'd like to contribute to Apache SeaTunnel on #13482. Before editing, could you confirm these three points?
I have not run the reproductions yet and will wait for confirmation before changing code.
zhangshenghang commentedon Nov 26, 2026
I reproduced both paths on
devand opened #13483 with a fix plus E2E coverage: the terminal job cleanup now shuts down every pipeline's checkpoint-ID counter, including pipelines that never started. The newCheckpointIdCounterTerminalCleanupITfails on unmodifieddevfor both PENDING-cancel and REJECT, and passes with the fix.