From f3ad422c1952bf8f68dca4f7d660f4543831d21b Mon Sep 17 00:00:00 2001 From: Vladimir Rodionov Date: Wed, 20 Mar 2019 16:11:59 -0700 Subject: [PATCH] HBase-22075: Potential data loss when MOB compaction fails --- .../compactions/PartitionedMobCompactor.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/compactions/PartitionedMobCompactor.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/compactions/PartitionedMobCompactor.java index 9f1ab965a1..01bfe4bc5e 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/compactions/PartitionedMobCompactor.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/compactions/PartitionedMobCompactor.java @@ -621,7 +621,6 @@ public class PartitionedMobCompactor extends MobCompactor { long mobCells = 0; boolean cleanupTmpMobFile = false; boolean cleanupBulkloadDirOfPartition = false; - boolean cleanupCommittedMobFile = false; boolean closeReaders= true; try { @@ -673,10 +672,8 @@ public class PartitionedMobCompactor extends MobCompactor { // commit mob file MobUtils.commitFile(conf, fs, filePath, mobFamilyDir, compactionCacheConfig); cleanupTmpMobFile = false; - cleanupCommittedMobFile = true; // bulkload the ref file bulkloadRefFile(connection, table, bulkloadPathOfPartition, filePath.getName()); - cleanupCommittedMobFile = false; newFiles.add(new Path(mobFamilyDir, filePath.getName())); } @@ -701,10 +698,6 @@ public class PartitionedMobCompactor extends MobCompactor { // delete the bulkload files in bulkloadPath deletePath(bulkloadPathOfPartition); } - - if (cleanupCommittedMobFile) { - deletePath(new Path(mobFamilyDir, filePath.getName())); - } } } @@ -828,8 +821,20 @@ public class PartitionedMobCompactor extends MobCompactor { private void bulkloadRefFile(Connection connection, Table table, Path bulkloadDirectory, String fileName) throws IOException { - // bulkload the ref file + // bulk load the reference file + LOG.debug("bulk load "+fileName+" from path="+bulkloadDirectory +" for table="+table); + int numSplitRetries = 1000; // let it be large value try { + Configuration conf = new Configuration(this.conf); + // Make sure we do not bail out due to number of exceeded attempts + // due to region splits, set it to a reasonably large number + int oldValue = conf.getInt(HConstants.BULKLOAD_MAX_RETRIES_NUMBER, 0); + if (oldValue < numSplitRetries) { + conf.setInt(HConstants.BULKLOAD_MAX_RETRIES_NUMBER, numSplitRetries); + } else { + // do not overwrite larger value + } + LoadIncrementalHFiles bulkload = new LoadIncrementalHFiles(conf); bulkload.doBulkLoad(bulkloadDirectory, connection.getAdmin(), table, connection.getRegionLocator(table.getName())); -- 2.17.2 (Apple Git-113)