{"record":{"id":"9b692aba10af0ac9","repo":"apache/hadoop","slug":"this-invalid-slot-index-slotidx","errorCode":null,"errorMessage":"{this}: invalid slot index {slotIdx}","messagePattern":"(.+?): invalid slot index (.+?)","errorType":"exception","errorClass":"InvalidRequestException","httpStatus":null,"severity":"warning","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/shortcircuit/ShortCircuitShm.java","lineNumber":581,"sourceCode":"   *\n   * This function looks at a slot which has already been initialized (by\n   * another process), and registers it with us.  Then, it returns the\n   * relevant Slot object.\n   *\n   * @return    The slot.\n   *\n   * @throws InvalidRequestException\n   *            If the slot index we're trying to allocate has not been\n   *            initialized, or is already in use.\n   */\n  synchronized public final Slot registerSlot(int slotIdx,\n      ExtendedBlockId blockId) throws InvalidRequestException {\n    if (slotIdx < 0) {\n      throw new InvalidRequestException(this + \": invalid negative slot \" +\n          \"index \" + slotIdx);\n    }\n    if (slotIdx >= slots.length) {\n      throw new InvalidRequestException(this + \": invalid slot \" +\n          \"index \" + slotIdx);\n    }\n    if (allocatedSlots.get(slotIdx)) {\n      throw new InvalidRequestException(this + \": slot \" + slotIdx +\n          \" is already in use.\");\n    }\n    Slot slot = new Slot(calculateSlotAddress(slotIdx), blockId);\n    if (!slot.isValid()) {\n      throw new InvalidRequestException(this + \": slot \" + slotIdx +\n          \" is not marked as valid.\");\n    }\n    slots[slotIdx] = slot;\n    allocatedSlots.set(slotIdx, true);\n    if (LOG.isTraceEnabled()) {\n      LOG.trace(this + \": registerSlot \" + slotIdx + \": allocatedSlots=\" + allocatedSlots +\n                  StringUtils.getStackTrace(Thread.currentThread()));\n    }\n    return slot;","sourceCodeStart":563,"sourceCodeEnd":599,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/shortcircuit/ShortCircuitShm.java#L563-L599","documentation":"Same datanode-side registerSlot path: the reported slot index is non-negative but at or beyond the segment's slot count (mmappedLength / 64). The client computed the index against a different (larger) segment than the one the datanode has registered, so the request is rejected with InvalidRequestException 'invalid slot index'.","triggerScenarios":"Client and datanode disagreeing on the shm segment size - the datanode restarted and created a smaller segment while the client kept the old, larger one, or version skew in shm sizing - and the client then requests short-circuit fds for a slot beyond the datanode's array.","commonSituations":"Datanode restart mid-session with long-lived clients; rolling upgrades mixing versions on the short-circuit path; races where the client maps a segment the datanode already discarded.","solutions":["Restart long-lived client processes after datanode restarts or upgrade rolls","Version-match client and datanode on the short-circuit path","Let the client recover: after InvalidRequestException it drops the shm and requests a new one; repeated failures warrant disabling short-circuit reads until state is clean"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  // datanode-side registration of client slots\n} catch (InvalidRequestException e) {\n  // index out of range for this segment: invalidate the client's shm so it requests a new one\n}","preventionTips":["Restart long-lived clients after datanode restarts or rolling upgrades","Monitor datanode logs for shm mismatches during upgrade rolls as an early skew signal"],"tags":["hdfs","short-circuit-read","shared-memory","slots","version-skew","datanode"],"backgroundTag":"shared-memory-slot-registration","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}