apache/seatunnel · error · TaskGroupContextNotFoundException

task group %s not found.

Error message

task group %s not found.

What it means

TaskExecutionService.getExecutionContext throws TaskGroupContextNotFoundException when no execution context (running or finished) exists for the requested TaskGroupLocation. It means this worker never deployed that task group, or its context was already removed after completion/cleanup.

Source

Thrown at seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/TaskExecutionService.java:316

        timerFlushWorker.shutdown();
    }

    /**
     * Gets the execution context for a task group. First checks active execution contexts, then
     * falls back to finished execution contexts.
     *
     * @param taskGroupLocation the location of the task group
     * @return the TaskGroupContext for the task group
     * @throws TaskGroupContextNotFoundException if the task group is not found
     */
    public TaskGroupContext getExecutionContext(TaskGroupLocation taskGroupLocation) {
        TaskGroupContext taskGroupContext = executionContexts.get(taskGroupLocation);

        if (taskGroupContext == null) {
            taskGroupContext = finishedExecutionContexts.get(taskGroupLocation);
        }
        if (taskGroupContext == null) {
            throw new TaskGroupContextNotFoundException(
                    String.format("task group %s not found.", taskGroupLocation));
        }
        return taskGroupContext;
    }

    /**
     * Gets the active execution context for a task group. Only checks active execution contexts,
     * does not check finished contexts.
     *
     * @param taskGroupLocation the location of the task group
     * @return the TaskGroupContext for the task group
     * @throws TaskGroupContextNotFoundException if the task group is not found or not active
     */
    public TaskGroupContext getActiveExecutionContext(TaskGroupLocation taskGroupLocation) {
        TaskGroupContext taskGroupContext = executionContexts.get(taskGroupLocation);

        if (taskGroupContext == null) {
            throw new TaskGroupContextNotFoundException(

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Confirm the task group was actually deployed to this worker (check the worker log for the corresponding deploy/deployment message for that TaskGroupLocation).
  2. If the node restarted, let the coordinator failover logic redeploy the task group (retrigger the job or wait for its retry).
  3. Check for version mismatches between coordinator and worker (same SeaTunnel version) — mismatched TaskGroupLocation serialization can cause lookups with stale IDs.
  4. If the task already finished, the context was legitimately removed; the caller should treat this as a finished task and stop sending control operations.
Defensive patterns

Strategy: try-catch

Validate before calling

// coordinator side: ensure the deploy operation for this TaskGroupLocation completed before sending control ops

Type guard

TaskGroupContext ctx = executionContexts.get(loc);
if (ctx == null) ctx = finishedExecutionContexts.get(loc);
if (ctx == null) return null; // caller decides to skip/redeploy

Try / catch

try {
    return taskExecutionService.getExecutionContext(taskGroupLocation);
} catch (TaskGroupContextNotFoundException e) {
    log.warn("Task group {} unknown on this worker (deployed elsewhere or cleaned up)", taskGroupLocation);
    throw e;
}

Prevention

When it happens

Trigger: runControlDeployment / runOnePrePublicationFailureAttempt / taskClassLoader (classloader lookups during task execution) asking for a TaskGroupLocation that is absent from both executionContexts and finishedExecutionContexts maps — e.g. after TaskExecutionService cleanup, node restart, or a stale/mismatched task group location sent by the coordinator.

Common situations: Coordinator failover sending control operations to a worker whose local task group was already cleaned up; duplicate or outdated task-group notifications after a task finished; node restarted mid-job and receiving operations for pre-restart task groups.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/4189036b64050ff3. Report an issue: GitHub.