{"record":{"id":"49275a165bf38ff0","repo":"apache/hadoop","slug":"next-value-iterator-interrupted","errorCode":null,"errorMessage":"next value iterator interrupted","messagePattern":"next value iterator interrupted","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/task/ReduceContextImpl.java","lineNumber":245,"sourceCode":"      // if this is the first record, we don't need to advance\n      if (firstValue) {\n        firstValue = false;\n        return value;\n      }\n      // if this isn't the first record and the next key is different, they\n      // can't advance it here.\n      if (!nextKeyIsSame) {\n        throw new NoSuchElementException(\"iterate past last value\");\n      }\n      // otherwise, go to the next key/value pair\n      try {\n        nextKeyValue();\n        return value;\n      } catch (IOException ie) {\n        throw new RuntimeException(\"next value iterator failed\", ie);\n      } catch (InterruptedException ie) {\n        // this is bad, but we can't modify the exception list of java.util\n        throw new RuntimeException(\"next value iterator interrupted\", ie);        \n      }\n    }\n\n    @Override\n    public void remove() {\n      throw new UnsupportedOperationException(\"remove not implemented\");\n    }\n\n    @Override\n    public void mark() throws IOException {\n      if (getBackupStore() == null) {\n        backupStore = new BackupStore<KEYIN,VALUEIN>(conf, taskid);\n      }\n      isMarked = true;\n      if (!inReset) {\n        backupStore.reinitialize();\n        if (currentKeyLength == -1) {\n          // The user has not called next() for this iterator yet, so","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/task/ReduceContextImpl.java#L227-L263","documentation":"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.","triggerScenarios":"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.","commonSituations":"Speculative execution enabled on straggler-prone clusters; YARN preemption hitting reduce containers; operators killing jobs during long reduce phases.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  reduce(key, context);\n} catch (RuntimeException e) {\n  if (e.getCause() instanceof InterruptedException) {\n    Thread.currentThread().interrupt(); // restore and exit cleanly\n    return;\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["mapreduce","reducer","interruption","speculative-execution","preemption"],"backgroundTag":"thread-interrupted","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}