From 160395c9f793dfa6458bde8bbb2973986e2fa3ff Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Mon, 8 Nov 2010 17:49:58 +0000 Subject: [PATCH] HBASE-3083: Major compaction check should use new timestamp meta information in HFiles (rather than dfs timestamp) along with TTL to allow major even if single file git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1032649 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 3 +++ .../hadoop/hbase/regionserver/Store.java | 20 +++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 611c966b734..b384ec475d9 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1115,6 +1115,9 @@ Release 0.90.0 - Unreleased HBASE-3201 Add accounting of empty regioninfo_qualifier rows in meta to hbasefsck. HBASE-3048 unify code for major/minor compactions (Amit via jgray) + HBASE-3083 Major compaction check should use new timestamp meta + information in HFiles (rather than dfs timestamp) along with + TTL to allow major even if single file NEW FEATURES diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java b/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java index 8cabe271200..a5d3c36b87b 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/Store.java @@ -785,19 +785,23 @@ public class Store implements HeapSize { majorCompactionTime == 0) { return result; } + // TODO: Use better method for determining stamp of last major (HBASE-2990) long lowTimestamp = getLowestTimestamp(fs, filesToCompact.get(0).getPath().getParent()); long now = System.currentTimeMillis(); if (lowTimestamp > 0l && lowTimestamp < (now - this.majorCompactionTime)) { // Major compaction time has elapsed. - long elapsedTime = now - lowTimestamp; - if (filesToCompact.size() == 1 && - filesToCompact.get(0).isMajorCompaction() && - (this.ttl == HConstants.FOREVER || elapsedTime < this.ttl)) { - if (LOG.isDebugEnabled()) { - LOG.debug("Skipping major compaction of " + this.storeNameStr + - " because one (major) compacted file only and elapsedTime " + - elapsedTime + "ms is < ttl=" + this.ttl); + if (filesToCompact.size() == 1) { + // Single file + StoreFile sf = filesToCompact.get(0); + long oldest = now - sf.getReader().timeRangeTracker.minimumTimestamp; + if (sf.isMajorCompaction() && + (this.ttl == HConstants.FOREVER || oldest < this.ttl)) { + if (LOG.isDebugEnabled()) { + LOG.debug("Skipping major compaction of " + this.storeNameStr + + " because one (major) compacted file only and oldestTime " + + oldest + "ms is < ttl=" + this.ttl); + } } } else { if (LOG.isDebugEnabled()) {