apache/hadoop · error · YarnException
Duration of a task shouldn't be less or equal to 0!
Error message
Duration of a task shouldn't be less or equal to 0!
What it means
Thrown by the Hadoop Scheduler Load Simulator (SLS) when TaskContainerDefinition.Builder.build() calls validateAndGetDuration(). The duration is resolved from builder.duration ('duration' in the task JSON), then builder.durationLegacy ('duration.ms'), then taskFinish - taskStart; if none is set (all default to -1, leaving duration == 0) or the resolved value is <= 0, a YarnException is thrown because SLS cannot schedule a container with zero or negative runtime.
Source
Thrown at hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/TaskContainerDefinition.java:241
taskContainerDef.allocationId = this.allocationId;
taskContainerDef.executionType = this.executionType;
taskContainerDef.hostname = this.hostname;
return taskContainerDef;
}
private long validateAndGetDuration(Builder builder) throws YarnException {
long duration = 0;
if (builder.duration != -1) {
duration = builder.duration;
} else if (builder.durationLegacy != -1) {
duration = builder.durationLegacy;
} else if (builder.taskStart != -1 && builder.taskFinish != -1) {
duration = builder.taskFinish - builder.taskStart;
}
if (duration <= 0) {
throw new YarnException("Duration of a task shouldn't be less or equal"
+ " to 0!");
}
return duration;
}
}
}
View on GitHub (pinned to 2add963021)
Solutions
- Add an explicit positive "duration" (milliseconds) to every task object in the SLS input JSON
- Alternatively supply "duration.ms", or both start and finish timestamps with finish strictly greater than start
- Validate the workload file before running SLS: for each task assert that a positive duration can be derived from duration/duration.ms/(finish-start)
- If converting rumen traces, filter out or repair tasks whose finish time is not after start time
Example fix
// before (sls-input.json task)
{"type" : "map", "priority" : 1, "duration_ms" : 100}
// after
{"type" : "map", "priority" : 1, "duration" : 100} Defensive patterns
Strategy: validation
Validate before calling
// before running SLS, verify every task yields a positive duration
ObjectMapper mapper = new ObjectMapper();
JsonNode root = mapper.readTree(new File("sls-input.json"));
for (JsonNode job : root.get("am")) { /* am-level check as needed */ }
for (JsonNode task : root.get("jobs")) {
long d = task.path("duration").asLong(-1);
if (d == -1) d = task.path("duration.ms").asLong(-1);
if (d == -1 && task.has("start") && task.has("finish")) d = task.get("finish").asLong() - task.get("start").asLong();
if (d <= 0) throw new IllegalArgumentException("Task with non-positive duration: " + task);
} Try / catch
catch (YarnException e) when building TaskContainerDefinition; report the offending task entry and stop the simulation run instead of letting it abort mid-load.
Prevention
- Add duration to every task object when authoring SLS JSON; treat it as a required field
- Keep a lint script (jq or the Java check above) in CI for workload files
- When generating workloads from rumen traces, filter tasks whose finish <= start
When it happens
Trigger: Building a TaskContainerDefinition (SLSRunner/SyntheticApplication parsing an sls input JSON, or rumen-trace conversion) where a task entry: omits 'duration', 'duration.ms', and both start/finish timestamps; sets duration to 0 or a negative number; or has taskFinish <= taskStart (reversed or equal timestamps).
Common situations: Hand-edited SLS JSON workload files with a typo'd key (e.g. 'duration_ms' instead of 'duration.ms'), traces exported with missing/zero timestamps, reusing old sample files whose tasks only carry start times, or copying durations in seconds where milliseconds were expected and rounding to 0.
Understand the failure class
Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.
Related errors
- Can't find the queue by the given name: {}! Please check if
- Can't find the queue by the given name: {}! Please check if
- ${diskValidator} DiskValidator class not found.
- dir + " is not a directory!"
- Invalid VECSUM_TYPE environment variable. Valid values are
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/c7e9961c864ce2f4.
Report an issue: GitHub.