busbey commented on a change in pull request #1022: HBASE-23680 
RegionProcedureStore missing cleaning of hfile archive
URL: https://github.com/apache/hbase/pull/1022#discussion_r366475845
 
 

 ##########
 File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/procedure2/store/region/RegionFlusherAndCompactor.java
 ##########
 @@ -136,9 +156,43 @@ static void setupConf(Configuration conf) {
       flushPerChanges, flushIntervalMs);
   }
 
+  private boolean isHFileDeleteable(FileStatus status) {
+    long currentTime = EnvironmentEdgeManager.currentTime();
+    long time = status.getModificationTime();
+    long life = currentTime - time;
+    if (LOG.isTraceEnabled()) {
+      LOG.trace("HFile life: {}ms, ttl: {}ms, current: {}, from: {}", life, 
compactedHFileTTLMs,
+        currentTime, time);
+    }
+    if (life < 0) {
+      LOG.warn("Found a hfile ({}) newer than current time ({} < {}), probably 
a clock skew",
+        status.getPath(), currentTime, time);
+      return false;
+    }
+    return life > compactedHFileTTLMs;
+  }
+
+  void cleanupCompactedHFiles() throws IOException {
+    HStore store = Iterables.getOnlyElement(region.getStores());
+    // our HFiles are on the WAL file system, but the global HFile archive 
directory is on the
+    // root(HFile) file system, we can not move between two different file 
systems. So here we have
+    // to implement our own TTL cleaner.
+    Path archiveDir = HFileArchiveUtil.getStoreArchivePath(conf, 
region.getRegionInfo(),
+      store.getColumnFamilyDescriptor().getName());
+    FileSystem fs = archiveDir.getFileSystem(conf);
+
+    for (FileStatus status : fs.listStatus(archiveDir)) {
+      if (isHFileDeleteable(status)) {
 
 Review comment:
   We should be asking the other cleaner delegates if it's okay to delete these 
files. I could see it being either the WAL cleaner delegates or the HFile 
Cleaner delegates, but it needs to be one of them.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to