busbey commented on a change in pull request #921: HBASE-22749: Distributed MOB 
compactions
URL: https://github.com/apache/hbase/pull/921#discussion_r359028398
 
 

 ##########
 File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/mob/DefaultMobStoreCompactor.java
 ##########
 @@ -326,47 +485,101 @@ protected boolean performCompaction(FileDetails fd, 
InternalScanner scanner, Cel
       progress.cancel();
       throw new InterruptedIOException(
           "Interrupted while control throughput of compacting " + 
compactionName);
+    } catch (IOException t) {
+      LOG.error("Mob compaction failed for region:{} ", 
store.getRegionInfo().getEncodedName());
+      throw t;
     } finally {
       // Clone last cell in the final because writer will append last cell 
when committing. If
       // don't clone here and once the scanner get closed, then the memory of 
last cell will be
       // released. (HBASE-22582)
       ((ShipperListener) writer).beforeShipped();
       throughputController.finish(compactionName);
       if (!finished && mobFileWriter != null) {
+        // Remove all MOB references because compaction failed
+        mobRefSet.get().clear();
+        // Abort writer
+        LOG.debug("Aborting writer for {} because of a compaction failure",
+          mobFileWriter.getPath());
         abortWriter(mobFileWriter);
       }
-      if (!finished && delFileWriter != null) {
-        abortWriter(delFileWriter);
-      }
     }
-    if (delFileWriter != null) {
-      if (deleteMarkersCount > 0) {
-        // If the del file is not empty, commit it.
-        // If the commit fails, the compaction is re-performed again.
-        delFileWriter.appendMetadata(fd.maxSeqId, major, deleteMarkersCount);
-        delFileWriter.close();
-        mobStore.commitFile(delFileWriter.getPath(), path);
-      } else {
-        // If the del file is empty, delete it instead of committing.
-        abortWriter(delFileWriter);
-      }
+
+    // Commit last MOB writer
+    commitOrAbortMobWriter(mobFileWriter, fd.maxSeqId, mobCells, major);
+
+    mobStore.updateCellsCountCompactedFromMob(cellsCountCompactedFromMob);
+    mobStore.updateCellsCountCompactedToMob(cellsCountCompactedToMob);
+    mobStore.updateCellsSizeCompactedFromMob(cellsSizeCompactedFromMob);
+    mobStore.updateCellsSizeCompactedToMob(cellsSizeCompactedToMob);
+    progress.complete();
+    return true;
+  }
+
+  private long getLength(StoreFileWriter mobFileWriter) throws IOException {
+    return mobFileWriter.getPos();
+  }
+
+  private StoreFileWriter newMobWriter(FileDetails fd/* , boolean compactMOBs 
*/)
+      throws IOException {
+    try {
+      StoreFileWriter mobFileWriter = mobStore.createWriterInTmp(new 
Date(fd.latestPutTs),
+        fd.maxKeyCount, compactionCompression, 
store.getRegionInfo().getStartKey(), true);
+      LOG.debug("New MOB writer created={}", 
mobFileWriter.getPath().getName());
+      // Add reference we get for compact MOB
+      mobRefSet.get().add(mobFileWriter.getPath().getName());
+      return mobFileWriter;
+    } catch (IOException e) {
+      // Bailing out
+      LOG.error("Failed to create mob writer, ", e);
+      throw e;
     }
+  }
+
+  private void commitOrAbortMobWriter(StoreFileWriter mobFileWriter, long 
maxSeqId, long mobCells,
+      boolean major) throws IOException {
+    // Commit or abort major mob writer
+    // If IOException happens during below operation, some
+    // MOB files can be committed partially, but corresponding
+    // store file won't be committed, therefore these MOB files
+    // become orphans and will be deleted during next MOB cleaning chore cycle
+
     if (mobFileWriter != null) {
+      LOG.info("Commit or abort size={} mobCells={} major={} file={}", 
mobFileWriter.getPos(),
+        mobCells, major, mobFileWriter.getPath().getName());
+      Path path =
+          MobUtils.getMobFamilyPath(conf, store.getTableName(), 
store.getColumnFamilyName());
       if (mobCells > 0) {
         // If the mob file is not empty, commit it.
-        mobFileWriter.appendMetadata(fd.maxSeqId, major, mobCells);
+        mobFileWriter.appendMetadata(maxSeqId, major, mobCells);
         mobFileWriter.close();
         mobStore.commitFile(mobFileWriter.getPath(), path);
       } else {
         // If the mob file is empty, delete it instead of committing.
+        LOG.debug("Aborting writer for {} because there are no MOB cells", 
mobFileWriter.getPath());
+        // Remove MOB file from reference set
+        mobRefSet.get().remove(mobFileWriter.getPath().getName());
         abortWriter(mobFileWriter);
       }
+    } else {
+      LOG.info("Mob file writer is null, skipping commit/abort.");
     }
-    mobStore.updateCellsCountCompactedFromMob(cellsCountCompactedFromMob);
-    mobStore.updateCellsCountCompactedToMob(cellsCountCompactedToMob);
-    mobStore.updateCellsSizeCompactedFromMob(cellsSizeCompactedFromMob);
-    mobStore.updateCellsSizeCompactedToMob(cellsSizeCompactedToMob);
-    progress.complete();
-    return true;
   }
+
+  protected static String createKey(TableName tableName, String encodedName,
 
 Review comment:
   unused in this file?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to