{"record":{"id":"955ca03039c31acf","repo":"apache/hadoop","slug":"cannot-create-data-block-until-previous-block-is-c","errorCode":null,"errorMessage":"Cannot create Data Block until previous block is closed.","messagePattern":"Cannot create Data Block until previous block is closed\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/file/tfile/BCFile.java","lineNumber":422,"sourceCode":"     * @throws IOException\n     */\n    public BlockAppender prepareMetaBlock(String name) throws IOException,\n        MetaBlockAlreadyExists {\n      return prepareMetaBlock(name, getDefaultCompressionAlgorithm());\n    }\n\n    /**\n     * Create a Data Block and obtain an output stream for adding data into the\n     * block. There can only be one BlockAppender stream active at any time.\n     * Data Blocks may not be created after the first Meta Blocks. The caller\n     * must call BlockAppender.close() to conclude the block creation.\n     * \n     * @return The BlockAppender stream\n     * @throws IOException\n     */\n    public BlockAppender prepareDataBlock() throws IOException {\n      if (blkInProgress == true) {\n        throw new IllegalStateException(\n            \"Cannot create Data Block until previous block is closed.\");\n      }\n\n      if (metaBlkSeen == true) {\n        throw new IllegalStateException(\n            \"Cannot create Data Block after Meta Blocks.\");\n      }\n\n      DataBlockRegister dbr = new DataBlockRegister();\n\n      WBlockState wbs =\n          new WBlockState(getDefaultCompressionAlgorithm(), out,\n              fsOutputBuffer, conf);\n      BlockAppender ba = new BlockAppender(dbr, wbs);\n      blkInProgress = true;\n      return ba;\n    }\n","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/file/tfile/BCFile.java#L404-L440","documentation":"Error \"Cannot create Data Block until previous block is closed.\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/file/tfile/BCFile.java:422 when the library encounters an invalid state.","commonSituations":"Occurs when a new Data Block is started while a previous block is still open. Close the previous block before preparing a new data block.","solutions":["Close the previous block appender before creating a new data block."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}