apache/hadoop · error · IllegalStateException
Cannot create Meta Block until previous block is closed.
Error message
Cannot create Meta Block until previous block is closed.
What it means
BCFile allows only one active BlockAppender at a time; prepareMetaBlock was called while the previous block's appender was still open (blkInProgress == true), so the new meta block cannot be started yet.
Solutions
- Close the previous block before preparing a new meta block; do not interleave block creation.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/file/tfile/BCFile.java:351 when the library encounters an invalid state.
Common situations: Occurs when a new Meta Block is started while a previous block is still open. Close the previous block before preparing a new meta block.
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/4de3eaae230fd7a1.
Report an issue: GitHub.
Appendix: source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/file/tfile/BCFile.java:351
out.writeLong(offsetIndexMeta);
API_VERSION.write(out);
Magic.write(out);
out.flush();
}
} finally {
closed = true;
}
}
private Algorithm getDefaultCompressionAlgorithm() {
return dataIndex.getDefaultCompressionAlgorithm();
}
private BlockAppender prepareMetaBlock(String name, Algorithm compressAlgo)
throws IOException, MetaBlockAlreadyExists {
if (blkInProgress == true) {
throw new IllegalStateException(
"Cannot create Meta Block until previous block is closed.");
}
if (metaIndex.getMetaByName(name) != null) {
throw new MetaBlockAlreadyExists("name=" + name);
}
MetaBlockRegister mbr = new MetaBlockRegister(name, compressAlgo);
WBlockState wbs =
new WBlockState(compressAlgo, out, fsOutputBuffer, conf);
BlockAppender ba = new BlockAppender(mbr, wbs);
blkInProgress = true;
metaBlkSeen = true;
return ba;
}
/**
* Create a Meta Block and obtain an output stream for adding data into theView on GitHub (pinned to 2add963021)