apache/hadoop · error · InvalidRequestException
there is no shared memory segment registered with shmId {}
Error message
there is no shared memory segment registered with shmId {} What it means
ShortCircuitRegistry.registerSlot() maps a client's shared-memory slot (SlotId = shmId + slotIdx) to an ExtendedBlockId. It first looks up the ShmId in its segments map; an unknown shmId means the DataNode has no registered short-circuit shared memory segment with that id, so it throws InvalidRequestException, which is serialized back to the DFS client over the domain socket / client-datanode protocol.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ShortCircuitRegistry.java:352
if (LOG.isTraceEnabled()) {
LOG.trace("createNewMemorySegment: created " + info.shmId);
}
return info;
}
public synchronized void registerSlot(ExtendedBlockId blockId, SlotId slotId,
boolean isCached) throws InvalidRequestException {
if (!enabled) {
if (LOG.isTraceEnabled()) {
LOG.trace(this + " can't register a slot because the " +
"ShortCircuitRegistry is not enabled.");
}
throw new UnsupportedOperationException();
}
ShmId shmId = slotId.getShmId();
RegisteredShm shm = segments.get(shmId);
if (shm == null) {
throw new InvalidRequestException("there is no shared memory segment " +
"registered with shmId " + shmId);
}
Slot slot = shm.registerSlot(slotId.getSlotIdx(), blockId);
if (isCached) {
slot.makeAnchorable();
} else {
slot.makeUnanchorable();
}
boolean added = slots.put(blockId, slot);
Preconditions.checkState(added);
if (LOG.isTraceEnabled()) {
LOG.trace(this + ": registered " + blockId + " with slot " +
slotId + " (isCached=" + isCached + ")");
}
}
public synchronized void unregisterSlot(SlotId slotId)
throws InvalidRequestException {View on GitHub (pinned to 2add963021)
Solutions
- Client side: discard the stale shared-memory segment on InvalidRequestException and re-establish it (new requestShortCircuitShm) before retrying the short-circuit read
- Falling back to normal (non-short-circuit) reads after this error is safe and automatic in most client versions - keep the fallback enabled
- Operator side: if this floods logs after a DN restart, that is expected churn; ensure clients eventually refresh rather than pinning dead segments
Defensive patterns
Strategy: retry
Validate before calling
// client side: only use SlotIds from segments you successfully created
if (shm == null || !shm.isValid()) { shm = requestShortCircuitShm(dn); } // re-establish before registering slots Try / catch
catch (InvalidRequestException e) { // from requestShortCircuitFds with a SlotId
if (e.getMessage().contains("no shared memory segment")) {
discardShmAndReestablish(); // drop stale shmId, requestShortCircuitShm again, then retry once
} else throw e;
} Prevention
- Invalidate cached ShortCircuitSharedMemorySegment on any DN restart or InvalidRequestException
- Keep dfs.domain.socket.path stable across restarts so segment handoff stays valid
When it happens
Trigger: A client sends a slot registration (block request with a SlotId) whose shmId was never established via a successful requestShortCircuitShm handshake - e.g., the segment was already torn down (DN restart, registry shutdown/re-enable, idle eviction) and the client retries with the stale shmId, or a fabricated/duplicated slot request.
Common situations: Client holds a cached ShortCircuitSharedMemorySegment across a DataNode restart or ShortCircuitRegistry flush; races between 'shutdown()' (which clears segments) and in-flight slot requests; tests hammering short-circuit reads (dfs.client.read.shortcircuit=true with dfs.domain.socket.path configured) against a restarted DN.
Related errors
- failed to allocate new BlockReader at position {}
- the datanode {} failed to pass a file descriptor (might have
- {this}: slot {slotIdx} does not exist.
- {this}: invalid negative slot index {slotIdx}
- {this}: invalid slot index {slotIdx}
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/c4ea91ea82c37932.
Report an issue: GitHub.