apache/hadoop · error · RuntimeException
next value iterator interrupted
Error message
next value iterator interrupted
What it means
ValueIterator.next() wraps an InterruptedException from nextKeyValue() as RuntimeException('next value iterator interrupted', ie) because java.util.Iterator cannot throw checked exceptions. It almost always accompanies the task being stopped — speculative-kill victim, preemption, or JVM shutdown — rather than a user bug.
Source
Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/task/ReduceContextImpl.java:245
// if this is the first record, we don't need to advance
if (firstValue) {
firstValue = false;
return value;
}
// if this isn't the first record and the next key is different, they
// can't advance it here.
if (!nextKeyIsSame) {
throw new NoSuchElementException("iterate past last value");
}
// otherwise, go to the next key/value pair
try {
nextKeyValue();
return value;
} catch (IOException ie) {
throw new RuntimeException("next value iterator failed", ie);
} catch (InterruptedException ie) {
// this is bad, but we can't modify the exception list of java.util
throw new RuntimeException("next value iterator interrupted", ie);
}
}
@Override
public void remove() {
throw new UnsupportedOperationException("remove not implemented");
}
@Override
public void mark() throws IOException {
if (getBackupStore() == null) {
backupStore = new BackupStore<KEYIN,VALUEIN>(conf, taskid);
}
isMarked = true;
if (!inReset) {
backupStore.reinitialize();
if (currentKeyLength == -1) {
// The user has not called next() for this iterator yet, soView on GitHub (pinned to 2add963021)
Solutions
- Check AM/RM logs for why the task was stopped (speculation, preemption) — the interrupt is the symptom
- If frequent, tune down mapreduce.map.speculative / mapreduce.reduce.speculative or scheduler preemption settings
- Do not swallow interrupts in custom Writable readFields implementations
Defensive patterns
Strategy: try-catch
Try / catch
try {
reduce(key, context);
} catch (RuntimeException e) {
if (e.getCause() instanceof InterruptedException) {
Thread.currentThread().interrupt(); // restore and exit cleanly
return;
}
throw e;
} Prevention
- Expect interruption during speculation/preemption; keep cleanup paths interrupt-safe
- Tune speculative execution if it kills healthy reducers often
- Never swallow interrupts in readFields loops
When it happens
Trigger: The task runner interrupts the reducer thread: the task lost a speculative race, containers are preempted by the scheduler, or the job was killed while the reducer was reading records.
Common situations: Speculative execution enabled on straggler-prone clusters; YARN preemption hitting reduce containers; operators killing jobs during long reduce phases.
Related errors
- Invoking cleanUpPartialOutputForTask() from non @Preemptable
- Failed to delete {pTask}
- hasNext failed
- next value iterator failed
- iterate past last value
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/49275a165bf38ff0.
Report an issue: GitHub.