{"record":{"id":"57054c05af75d885","repo":"apache/hadoop","slug":"this-slot-slotidx-is-not-marked-as-valid","errorCode":null,"errorMessage":"{this}: slot {slotIdx} is not marked as valid.","messagePattern":"(.+?): slot (.+?) is not marked as valid\\.","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":590,"sourceCode":"   *            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;\n  }\n\n  /**\n   * Unregisters a slot.\n   *\n   * This doesn't alter the contents of the slot.  It just means\n   *\n   * @param slotIdx  Index of the slot to unregister.\n   */","sourceCodeStart":572,"sourceCodeEnd":608,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/shortcircuit/ShortCircuitShm.java#L572-L608","documentation":"Datanode-side registerSlot's final check reads the slot's valid flag in the shared memory itself. The client is expected to mark its allocated slot valid (Slot.makeValid writes a nonzero word into the segment) before the datanode registers it; reading zero means the write was not performed or not yet visible, so registration aborts with InvalidRequestException 'not marked as valid'.","triggerScenarios":"DataXceiver handling a short-circuit fds request whose SlotId points at a slot whose word still reads 0: a client/datanode race (registration arriving before the client's makeValid write lands), a memory-visibility problem across the mmap, or a nonstandard client that skips the step.","commonSituations":"Tight request races on loaded machines; custom clients built against Hadoop internals; unusual JVMs with weak cross-process visibility behavior on mmapped memory.","solutions":["Treat as transient: retry the open - the slot is normally valid moments later","Restart the client if the error floods the datanode log","Ensure unmodified Hadoop client builds are in use on the short-circuit path","If persistent, capture trace logs on org.apache.hadoop.hdfs.shortcircuit and file a JIRA"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  // open with short-circuit reads\n} catch (InvalidRequestException e) {\n  // slot valid-flag not visible yet (race): brief backoff and retry once\n}","preventionTips":["Use unmodified Hadoop client builds on the short-circuit path","Report persistent occurrences with trace logs (org.apache.hadoop.hdfs.shortcircuit) - it can indicate a real visibility bug"],"tags":["hdfs","short-circuit-read","shared-memory","slots","race-condition","memory-visibility"],"backgroundTag":"shared-memory-slot-registration","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}