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

 ##########
 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);
 
 Review comment:
   We don't need to log here because the exception we throw will eventually get 
logged at ERROR by CompactSplit here:
   
   ```
         } catch (IOException ex) {
           IOException remoteEx =
               ex instanceof RemoteException ? ((RemoteException) 
ex).unwrapRemoteException() : ex;
           LOG.error("Compaction failed " + this, remoteEx);
   ```
   
   Instead wrap `e` with an IOException that includes the detail "Failed to 
create mob writer" and include the store we were trying to make a writer for.

----------------------------------------------------------------
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