apache/hadoop · error · IOException

MROutput/MRErrThread failed:

Error message

MROutput/MRErrThread failed:

What it means

Reducer-side twin of the mapper check: inside the reduce loop over values, PipeReducer.reduce() sees outerrThreadsThrowable set (the output or stderr reader thread for the piped reducer died) and throws IOException('MROutput/MRErrThread failed:', outerrThreadsThrowable) after calling mapRedFinished(). The cause chain holds the thread's original exception.

Source

Thrown at hadoop-tools/hadoop-streaming/src/main/java/org/apache/hadoop/streaming/PipeReducer.java:97

    this.numOfReduceOutputKeyFields = job_.getInt("stream.num.reduce.output.key.fields", 1);
  }

  public void reduce(Object key, Iterator values, OutputCollector output,
                     Reporter reporter) throws IOException {

    // init
    if (doPipe_ && outThread_ == null) {
      startOutputThreads(output, reporter);
    }
    try {
      while (values.hasNext()) {
        Writable val = (Writable) values.next();
        numRecRead_++;
        maybeLogRecord();
        if (doPipe_) {
          if (outerrThreadsThrowable != null) {
            mapRedFinished();
            throw new IOException("MROutput/MRErrThread failed:",
                outerrThreadsThrowable);
          }
          inWriter_.writeKey(key);
          inWriter_.writeValue(val);
        } else {
          // "identity reduce"
          output.collect(key, val);
        }
      }
      if(doPipe_ && skipping) {
        //flush the streams on every record input if running in skip mode
        //so that we don't buffer other records surrounding a bad record. 
        clientOut_.flush();
      }
    } catch (IOException io) {
      // a common reason to get here is failure of the subprocess.
      // Document that fact, if possible.
      String extraInfo = "";

View on GitHub (pinned to 2add963021)

Solutions

  1. Inspect the wrapped cause in the task log (MROutputThread/MRErrThread stack trace just before this IOException)
  2. Conform reducer stdout to key\tvalue lines; move logs/warnings to stderr
  3. Match stream.num.reduce.output.key.fields and any custom reader class to what the tool actually prints
  4. Test the reducer tool locally: cat input | reducer.sh and verify clean output and exit 0
Defensive patterns

Strategy: try-catch

Validate before calling

// preflight for the reducer tool: local pipeline smoke test
// sh -c 'cat sample-group.txt | ./my_reducer.sh' must print clean key\tvalue lines and exit 0

Try / catch

catch IOException from reduce(); inspect the cause chain for the failed reader thread's exception and fix the output-format or tool-crash root cause; retrying the task without changes will fail identically.

Prevention

When it happens

Trigger: With -reducer as an external tool, the thread reading reducer stdout or stderr fails mid-reduce — output that violates the expected format, pipe breakage when the reducer tool exits early, or custom stream.reduce.output.reader.class parse errors — and the next iteration of the value loop aborts.

Common situations: Reducer scripts emitting headers/debug lines to stdout, key-field count misconfiguration (stream.num.reduce.output.key.fields), reducers crashing partway through a value stream, or aggregator scripts buffering incorrectly and dying; wrapped cause in logs identifies which thread and why.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/aadc96a93d7fd4eb. Report an issue: GitHub.