apache/hadoop · error · IOException
Interrupted while waiting for the writer
Error message
Interrupted while waiting for the writer
What it means
At the end of the map phase, MapOutputBuffer.flush() performs the final spill(s) under spillLock, waiting on spillDone until the background writer catches up, then merges the spill parts. If the collector thread is interrupted during that wait, the InterruptedException is wrapped in this IOException - the attempt was being terminated at completion time.
Source
Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/MapTask.java:1519
if ((kvbend + METASIZE) % kvbuffer.length !=
equator - (equator % METASIZE)) {
// spill finished
resetSpill();
}
if (kvindex != kvend) {
kvend = (kvindex + NMETA) % kvmeta.capacity();
bufend = bufmark;
LOG.info("Spilling map output");
LOG.info("bufstart = " + bufstart + "; bufend = " + bufmark +
"; bufvoid = " + bufvoid);
LOG.info("kvstart = " + kvstart + "(" + (kvstart * 4) +
"); kvend = " + kvend + "(" + (kvend * 4) +
"); length = " + (distanceTo(kvend, kvstart,
kvmeta.capacity()) + 1) + "/" + maxRec);
sortAndSpill();
}
} catch (InterruptedException e) {
throw new IOException("Interrupted while waiting for the writer", e);
} finally {
spillLock.unlock();
}
assert !spillLock.isHeldByCurrentThread();
// shut down spill thread and wait for it to exit. Since the preceding
// ensures that it is finished with its work (and sortAndSpill did not
// throw), we elect to use an interrupt instead of setting a flag.
// Spilling simultaneously from this thread while the spill thread
// finishes its work might be both a useful way to extend this and also
// sufficient motivation for the latter approach.
try {
spillThread.interrupt();
spillThread.join();
} catch (InterruptedException e) {
throw new IOException("Spill failed", e);
}
// release sort buffer before the merge
kvbuffer = null;View on GitHub (pinned to 2add963021)
Solutions
- Check AM/NodeManager logs for the kill command behind the interrupt
- Rerun the job; teardown races are transient
- If frequent, reduce speculation (mapreduce.map.speculative) or investigate why the AM kills late-stage attempts
Defensive patterns
Strategy: retry
Prevention
- Treat interrupts during flush as kill symptoms; let attempt retries absorb them
- Avoid killing jobs during map finalization windows when latency matters
- Keep map tasks short enough that kill races at completion are rare
When it happens
Trigger: Task kill or JVM shutdown interrupting flush() while the final spill (kvstart != kvend drain, inline sortAndSpill) is in flight; a speculative loser killed just after emitting its last record.
Common situations: Job killed during map finalization; speculation killing maps that are nearly done; NM eviction racing task close(); aggressive container kill timers.
Related errors
- Spill thread failed to initialize
- Buffer interrupted while waiting for the writer
- Spill failed
- Unable to rename {src} to {dst}: couldn't create parent dire
- Unable to rename {src} to {dst}
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/6f4bebb7c46300cb.
Report an issue: GitHub.