{"record":{"id":"e59177999fbcca58","repo":"apache/hadoop","slug":"this-invalid-negative-slot-index-slotidx","errorCode":null,"errorMessage":"{this}: invalid negative slot index {slotIdx}","messagePattern":"(.+?): invalid negative 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":577,"sourceCode":"  }\n\n  /**\n   * Register a slot.\n   *\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()) {","sourceCodeStart":559,"sourceCodeEnd":595,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/shortcircuit/ShortCircuitShm.java#L559-L595","documentation":"registerSlot(slotIdx, blockId) runs on the datanode (ShortCircuitRegistry.registerSlot, called from DataXceiver) when a client that allocated a slot in the shared segment reports it while requesting short-circuit file descriptors. A negative index can never be valid - calculateSlotAddress would point before the mapping - so the datanode rejects it with InvalidRequestException. This is a protocol violation or corrupted request, not a tunable condition.","triggerScenarios":"DataXceiver opRequestShortCircuitFds receiving a SlotId whose slot index is negative: a client-side bug, a corrupted slot id, or version skew where the two sides disagree on the slot id encoding.","commonSituations":"Mixing Hadoop versions across the short-circuit protocol; patched or custom client builds; essentially never seen on unmodified releases.","solutions":["Verify client and datanode run the exact same Hadoop release","Reproduce with trace logging on org.apache.hadoop.hdfs.shortcircuit to capture the offending slot index","Restart the client to re-establish clean shm state","If it persists on stock software, file a Hadoop JIRA with the trace logs"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Client side: never hand-build SlotId values; only use indices returned by the shm layer\nSlot slot = shm.allocAndRegisterSlot(blockId); // idx >= 0 guaranteed here","typeGuard":null,"tryCatchPattern":"try {\n  // datanode-side registration of client slots\n} catch (InvalidRequestException e) {\n  // reject the client request; client re-establishes a fresh shm\n}","preventionTips":["Version-match client and datanode; the slot-id encoding is protocol-coupled","Never construct or mutate SlotId / slot indices outside the short-circuit API"],"tags":["hdfs","short-circuit-read","shared-memory","slots","protocol-violation","datanode"],"backgroundTag":"shared-memory-slot-registration","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}