apache/flink · error · InvalidProgramException
Job was submitted in detached mode. Results of job execution
Error message
Job was submitted in detached mode. Results of job execution, such as accumulators, runtime, etc. are not available. Please make sure your program doesn't call an eager execution function [collect, print, printToErr, count].
What it means
Thrown by DetachedJobExecutionResult.getAccumulatorResult() when a detached job's result is queried for an accumulator. The message adds guidance about eager execution functions (collect, print, printToErr, count) that internally trigger accumulator retrieval and are incompatible with detached submission.
Source
Thrown at flink-core/src/main/java/org/apache/flink/core/execution/DetachedJobExecutionResult.java:56
"Please make sure your program doesn't call "
+ "an eager execution function [collect, print, printToErr, count]. ";
public static final String JOB_RESULT_MESSAGE =
"Results of job execution, such as accumulators,"
+ " runtime, etc. are not available. ";
public DetachedJobExecutionResult(final JobID jobID) {
super(jobID, -1, null);
}
@Override
public long getNetRuntime() {
throw new InvalidProgramException(DETACHED_MESSAGE + JOB_RESULT_MESSAGE);
}
@Override
public <T> T getAccumulatorResult(String accumulatorName) {
throw new InvalidProgramException(
DETACHED_MESSAGE + JOB_RESULT_MESSAGE + EAGER_FUNCTION_MESSAGE);
}
@Override
public Map<String, Object> getAllAccumulatorResults() {
throw new InvalidProgramException(DETACHED_MESSAGE + JOB_RESULT_MESSAGE);
}
@Override
public JobID getJobID() {
return super.getJobID();
}
@Override
public boolean isJobExecutionResult() {
return false;
}
View on GitHub (pinned to 2f3c205e92)
Solutions
- Run the job in attached mode (execution.attached=true) to enable accumulator retrieval.
- Remove collect/print/printToErr/count calls when the job must run detached; write results to a sink instead.
- Use a separate result-retrieval mechanism (e.g., queryable state or an external sink) for detached jobs.
Example fix
// before
DataStream<Integer> stream = ...;
List<Integer> results = stream.executeAndCollect(); // eager, fails in detached
// after (for detached)
stream.addSink(new MyExternalSink());
env.execute("job"); Defensive patterns
Strategy: validation
Validate before calling
if (result instanceof DetachedJobExecutionResult) {
throw new IllegalStateException("Accumulators unavailable in detached mode; remove collect/print");
} Type guard
static boolean isDetached(org.apache.flink.api.common.JobExecutionResult r) {
return r instanceof org.apache.flink.core.execution.DetachedJobExecutionResult;
} Try / catch
try {
Object acc = result.getAccumulatorResult(name);
} catch (InvalidProgramException e) {
if (e.getMessage().contains("eager execution function")) { /* run attached or use a sink */ }
} Prevention
- Remove collect/print/printToErr/count from detached jobs.
- Run in attached mode when eager results are needed.
- Use external sinks for detached result delivery.
When it happens
Trigger: Calling result.getAccumulatorResult(name) on a DetachedJobExecutionResult. More commonly, implicitly triggered by calling collect(), print(), printToErr(), or count() on a DataStream/Table in a detached job, since those sink into accumulators.
Common situations: Writing DataStream.collect() or print() in a job submitted with execution.attached=false or via sql-client in detached mode. Migration from attached to detached execution without removing eager sinks.
Related errors
- Job was submitted in detached mode. Results of job execution
- Cannot deserialize and unwrap accumulators properly.
- Cannot deserialize and unwrap accumulators properly.
- This JobSubmissionResult is not a JobExecutionResult.
- Multiple compatible client factories found for: {}.
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/74a65b604e8406dc.
Report an issue: GitHub.