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_r367181321
##########
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:
No not overkill. This is the specific mechanism I mentioned needing to feel
comfortable with this landing in branches where I will probably have to support
deployments.
I agree that the TTL cleaner is the only one needed by default.
At some point something will go wrong where I need to avoid things getting
cleaned out of archive. Being able to reuse a cleaner delegate that normally is
used with HFiles will make that easier. It's exactly the kind of operational
reuse that makes this implementation shift attractive.
----------------------------------------------------------------
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