{"record":{"id":"6df88115e93a25ba","repo":"apache/hadoop","slug":"hasnext-failed","errorCode":null,"errorMessage":"hasNext failed","messagePattern":"hasNext failed","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":197,"sourceCode":"  \n  BackupStore<KEYIN,VALUEIN> getBackupStore() {\n    return backupStore;\n  }\n  \n  protected class ValueIterator implements ReduceContext.ValueIterator<VALUEIN> {\n\n    private boolean inReset = false;\n    private boolean clearMarkFlag = false;\n\n    @Override\n    public boolean hasNext() {\n      try {\n        if (inReset && backupStore.hasNext()) {\n          return true;\n        } \n      } catch (Exception e) {\n        e.printStackTrace();\n        throw new RuntimeException(\"hasNext failed\", e);\n      }\n      return firstValue || nextKeyIsSame;\n    }\n\n    @Override\n    public VALUEIN next() {\n      if (inReset) {\n        try {\n          if (backupStore.hasNext()) {\n            backupStore.next();\n            DataInputBuffer next = backupStore.nextValue();\n            buffer.reset(next.getData(), next.getPosition(), next.getLength()\n                - next.getPosition());\n            value = valueDeserializer.deserialize(value);\n            return value;\n          } else {\n            inReset = false;\n            backupStore.exitResetMode();","sourceCodeStart":179,"sourceCodeEnd":215,"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#L179-L215","documentation":"ReduceContextImpl.ValueIterator.hasNext(), when replaying marked values (inReset after mark()/reset()), delegates to BackupStore.hasNext(); any exception there is wrapped as RuntimeException('hasNext failed', e) after printStackTrace. The underlying failure — typically local-disk IO while reading the backup store's spill files — is in the cause chain.","triggerScenarios":"A reducer uses mark()/reset() to re-iterate a large value group, and during reset-mode iteration the BackupStore spill files under the task's local dirs cannot be read (disk full, failed disk, spill corruption).","commonSituations":"Reducers that rewind over huge value groups (per-key aggregation needing two passes) on nodes with tight NodeManager local-disk space; disks failing under mapreduce.cluster.local.dir.","solutions":["Inspect the wrapped cause in the task log to identify the real IO failure","Check NodeManager local directories for space and disk health; the framework retries the task on another node","Avoid mark()/reset() rewind for very large key groups — structure the algorithm as a single pass or use secondary sort"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  while (values.hasNext()) { consume(values.next()); }\n} catch (RuntimeException e) {\n  log.error(\"Value iteration failed (backup store): {}\", e.getCause());\n  throw e; // let the task fail and be retried on a healthy node\n}","preventionTips":["Monitor NodeManager local-disk space on reduce-heavy nodes","Avoid mark()/reset() for very large value groups","Prefer secondary sort or a single-pass algorithm over rewind"],"tags":["mapreduce","reducer","iterator","backup-store","local-disk"],"backgroundTag":"backup-store-read-failure","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}