yuting sun created HBASE-29466: ---------------------------------- Summary: Failure in compacting createStoreFileAndReader causes commitPath files to be omitted Key: HBASE-29466 URL: https://issues.apache.org/jira/browse/HBASE-29466 Project: HBase Issue Type: Bug Reporter: yuting sun
{code:java} //代码占位符 {code} public List<HStoreFile> commitStoreFiles(List<Path> files, boolean isCompaction, boolean validate) throws IOException { List<HStoreFile> committedFiles = new ArrayList<>(files.size()); HRegionFileSystem hfs = ctx.getRegionFileSystem(); String familyName = ctx.getFamily().getNameAsString(); Path storeDir = hfs.getStoreDir(familyName); for (Path file : files) { try { if (validate) { validateStoreFile(file, isCompaction); } Path committedPath; // As we want to support writing to data directory directly, here we need to check whether // the store file is already in the right place if (file.getParent() != null && file.getParent().equals(storeDir)) { // already in the right place, skip renaming committedPath = file; } else { // Write-out finished successfully, move into the right spot committedPath = hfs.commitStoreFile(familyName, file); } *HStoreFile sf = createStoreFileAndReader(committedPath);* committedFiles.add(sf); } catch (IOException e) { LOG.error("Failed to commit store file {}", file, e); // Try to delete the files we have committed before. // It is OK to fail when deleting as leaving the file there does not cause any data // corruption problem. It just introduces some duplicated data which may impact read // performance a little when reading before compaction. for (HStoreFile sf : committedFiles) { Path pathToDelete = sf.getPath(); try { sf.deleteStoreFile(); } catch (IOException deleteEx) { LOG.warn(HBaseMarkers.FATAL, "Failed to delete committed store file {}", pathToDelete, deleteEx); } } throw new IOException("Failed to commit the flush", e); } } return committedFiles; } {code:java} //代码占位符 {code} If the createStoreFileAndReader process fails, only the committedFiles are rolled back and cleaned up, but the committedPath of this createStoreFileAndReader execution is not rolled back and cleaned up. Therefore, the committedPath cleanup logic is added. Please see if it is reasonable. -- This message was sent by Atlassian Jira (v8.20.10#820010)