{"record":{"id":"9a106764c56bd162","repo":"apache/hadoop","slug":"position-out-of-range-position-expected-0","errorCode":null,"errorMessage":"position out of range: {position} (expected: 0 - {count-1})","messagePattern":"position out of range: (.+?) \\(expected: 0 - (.+?)\\)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-shuffle/src/main/java/org/apache/hadoop/mapred/FadvisedFileRegion.java","lineNumber":112,"sourceCode":"    }\n\n  }\n\n  /**\n   * This method transfers data using local buffer. It transfers data from\n   * a disk to a local buffer in memory, and then it transfers data from the\n   * buffer to the target. This is used only if transferTo is disallowed in\n   * the configuration file. super.TransferTo does not perform well on Windows\n   * due to a small IO request generated. customShuffleTransfer can control\n   * the size of the IO requests by changing the size of the intermediate\n   * buffer.\n   */\n  @VisibleForTesting\n  long customShuffleTransfer(WritableByteChannel target, long position)\n          throws IOException {\n    long actualCount = this.count - position;\n    if (actualCount < 0 || position < 0) {\n      throw new IllegalArgumentException(\n              \"position out of range: \" + position +\n                      \" (expected: 0 - \" + (this.count - 1) + ')');\n    }\n    if (actualCount == 0) {\n      return 0L;\n    }\n\n    long trans = actualCount;\n    int readSize;\n    ByteBuffer byteBuffer = ByteBuffer.allocate(\n            Math.min(\n                    this.shuffleBufferSize,\n                    trans > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) trans));\n\n    while(trans > 0L &&\n            (readSize = fileChannel.read(byteBuffer, this.position+position)) > 0) {\n      //adjust counters and buffer limit\n      if(readSize < trans) {","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-shuffle/src/main/java/org/apache/hadoop/mapred/FadvisedFileRegion.java#L94-L130","documentation":"Error \"position out of range: {position} (expected: 0 - {count-1})\" thrown in apache/hadoop.","triggerScenarios":"Thrown by FadvisedFileRegion.position() when the requested shuffle position is outside [0, count-1] for the identified map output. Usually a corrupt or stale shuffle request; the reducer should retry the fetch from the correct offset.","commonSituations":"See trigger scenarios.","solutions":["Request a position within [0, count-1] of the FadvisedFileRegion; fix the caller's offset computation.","Validate shuffle request parameters so the requested region falls inside the map output file."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}