apache/hadoop · error · IOException
The file {} belonged to does not exist or it is not under co
Error message
The file {} belonged to does not exist or it is not under construction. What it means
checkUCBlock resolved the block's inode but the file is null, closed, or deleted, so it is not under construction and cannot accept block updates. The write session the caller believes is active has already ended (typically via lease recovery or completion).
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java:6049
assert hasWriteLock(RwLockMode.GLOBAL);
checkNameNodeSafeMode("Cannot get a new generation stamp and an "
+ "access token for block " + block);
// check stored block state
BlockInfo storedBlock = getStoredBlock(ExtendedBlock.getLocalBlock(block));
if (storedBlock == null) {
throw new IOException(block + " does not exist.");
}
if (storedBlock.getBlockUCState() != BlockUCState.UNDER_CONSTRUCTION) {
throw new IOException("Unexpected BlockUCState: " + block
+ " is " + storedBlock.getBlockUCState()
+ " but not " + BlockUCState.UNDER_CONSTRUCTION);
}
// check file inode
final INodeFile file = getBlockCollection(storedBlock);
if (file == null || !file.isUnderConstruction() || isFileDeleted(file)) {
throw new IOException("The file " + storedBlock +
" belonged to does not exist or it is not under construction.");
}
// check lease
if (clientName == null
|| !clientName.equals(file.getFileUnderConstructionFeature()
.getClientName())) {
throw new LeaseExpiredException("Lease mismatch: " + block +
" is accessed by a non lease holder " + clientName);
}
return file;
}
/**
* Client is reporting some bad block locations.
*/
void reportBadBlocks(LocatedBlock[] blocks) throws IOException {View on GitHub (pinned to 2add963021)
Solutions
- Check isFileClosed(path); if closed, restart via append if more data must be written
- Have the writer renew its lease (keep writing or keepalive) so recovery cannot steal the file
- Eliminate duplicate writers on the same path
Defensive patterns
Strategy: validation
Validate before calling
if (dfs.isFileClosed(path)) {
throw new IllegalStateException("File closed; reopen with append before block updates");
} Try / catch
try {
updateBlock(oldBlock, clientName, ...);
} catch (IOException e) {
if (e.getMessage().contains("not under construction")) {
recoverAndWaitThenAppend(path); // lease lost elsewhere: re-establish write
} else { throw e; }
} Prevention
- Keep the writer's lease renewed during idle periods
- Check isFileClosed before resuming writes after long pauses
When it happens
Trigger: updateBlock/nextGenerationStamp after the file was completed by another attempt, recovered by another client, or deleted while its block remained temporarily.
Common situations: Stale writers resuming after lease hard-limit expiry; duplicate task attempts where the first already closed the file.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Cannot complete block: block has not been COMMITTED by the c
- Recovery block {b} where it is not under construction.
- File is deleted: {} (inode {}) {}
- Client (={}) is not the lease owner (={}: {} (inode {}) {}
- DIR* NameSystem.internalReleaseLease: attempt to release a c
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/cd5004491771bf92.
Report an issue: GitHub.