apache/seatunnel · error · SeaTunnelEngineException

get job state error

Error message

get job state error

What it means

getJobDetailState is queried asynchronously through jobHistoryService; if the future throws (failure inside getJobDetailState or while reading the history IMap), it is rethrown as a SeaTunnelEngineException with this message. The caller cannot obtain the job's state, so the wait-for-job API errors instead of returning a JobResult.

Source

Thrown at seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/CoordinatorService.java:1556

                                    executorService));
        }
        return new PassiveCompletableFuture<>(voidCompletableFuture);
    }

    public PassiveCompletableFuture<JobResult> waitForJobComplete(long jobId) {
        // must wait for all job restore complete
        restoreAllJobFromMasterNodeSwitchFuture.join();
        JobMaster runningJobMaster = getJobMaster(jobId);
        if (runningJobMaster == null) {
            // Because operations on Imap cannot be performed within Operation.
            CompletableFuture<JobHistoryService.JobState> jobStateFuture =
                    CompletableFuture.supplyAsync(
                            () -> jobHistoryService.getJobDetailState(jobId), executorService);
            JobHistoryService.JobState jobState = null;
            try {
                jobState = jobStateFuture.get();
            } catch (Exception e) {
                throw new SeaTunnelEngineException("get job state error", e);
            }

            CompletableFuture<JobResult> future = new CompletableFuture<>();
            if (jobState == null) {
                future.complete(new JobResult(JobStatus.UNKNOWABLE, null));
            } else {
                future.complete(new JobResult(jobState.getJobStatus(), jobState.getErrorMessage()));
            }
            return new PassiveCompletableFuture<>(future);
        } else {
            return new PassiveCompletableFuture<>(runningJobMaster.getJobMasterCompleteFuture());
        }
    }

    public PassiveCompletableFuture<Void> cancelJob(long jobId) {
        JobMaster runningJobMaster = getJobMaster(jobId);
        if (runningJobMaster == null) {
            CompletableFuture<Void> future = new CompletableFuture<>();

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Read the caused-by exception to identify the underlying failure in getJobDetailState.
  2. Retry the query with backoff; transient IMap/cluster issues usually clear once the cluster is stable.
  3. Verify the jobId exists in job history (getJobMetrics) before waiting on its detailed state.
  4. Check cluster health (member liveness, IMap connectivity); restore history data if corrupted.

Example fix

// before
JobResult result = coordinatorService.waitForJobComplete(jobId).get();
// after: tolerate transient state query failure
try {
    JobResult result = coordinatorService.waitForJobComplete(jobId).get();
} catch (ExecutionException e) {
    if (e.getCause() instanceof SeaTunnelEngineException
            && e.getCause().getMessage().contains("get job state error")) {
        Thread.sleep(5000); // retry after cluster stabilizes
    } else { throw e; }
}
Defensive patterns

Strategy: try-catch

Validate before calling

// confirm the job exists in history before waiting on its state
JobMetrics m = jobClient.getJobMetrics(jobId);
if (m == null || m.equals(JobMetrics.empty())) {
    // job unknown; skip waiting on detailed state
}

Try / catch

try {
    JobResult result = coordinatorService.waitForJobComplete(jobId).get();
} catch (ExecutionException e) {
    if (e.getCause() instanceof SeaTunnelEngineException
            && e.getCause().getMessage().contains("get job state error")) {
        // retry with backoff, or fall back to getJobMetrics for status
    } else { throw e; }
}

Prevention

When it happens

Trigger: Calling waitForJobComplete / getJobResult APIs when jobHistoryService.getJobDetailState(jobId) throws — e.g. IMap access failure, concurrent cleanup of history records, or executor rejection.

Common situations: Querying job state during cluster shutdown or a network partition; history records concurrently removed while read; serialization issues in stored job state data.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


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