You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Guangxu Cheng (JIRA)" <ji...@apache.org> on 2017/11/07 10:34:00 UTC
[jira] [Updated] (HBASE-19199)
RatioBasedCompactionPolicy#shouldPerformMajorCompaction() always return
true when only one file needs to compact
[ https://issues.apache.org/jira/browse/HBASE-19199?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Guangxu Cheng updated HBASE-19199:
----------------------------------
Attachment: HBASE-19199.patch
> RatioBasedCompactionPolicy#shouldPerformMajorCompaction() always return true when only one file needs to compact
> ----------------------------------------------------------------------------------------------------------------
>
> Key: HBASE-19199
> URL: https://issues.apache.org/jira/browse/HBASE-19199
> Project: HBase
> Issue Type: Bug
> Affects Versions: 3.0.0, 1.3.1, 1.4.1, 1.5.0, 2.0.0-beta-1
> Reporter: Guangxu Cheng
> Assignee: Guangxu Cheng
> Attachments: HBASE-19199.patch
>
>
> {code:title=RatioBasedCompactionPolicy.java|borderStyle=solid}
> public boolean shouldPerformMajorCompaction(Collection<HStoreFile> filesToCompact)
> throws IOException {
> boolean result = false;
> long mcTime = getNextMajorCompactTime(filesToCompact);
> if (filesToCompact == null || filesToCompact.isEmpty() || mcTime == 0) {
> return result;
> }
> // TODO: Use better method for determining stamp of last major (HBASE-2990)
> long lowTimestamp = StoreUtils.getLowestTimestamp(filesToCompact);
> long now = EnvironmentEdgeManager.currentTime();
> if (lowTimestamp > 0L && lowTimestamp < (now - mcTime)) {
> String regionInfo;
> if (this.storeConfigInfo != null && this.storeConfigInfo instanceof HStore) {
> regionInfo = ((HStore)this.storeConfigInfo).getRegionInfo().getRegionNameAsString();
> } else {
> regionInfo = this.toString();
> }
> // Major compaction time has elapsed.
> long cfTTL = HConstants.FOREVER;
> if (this.storeConfigInfo != null) {
> cfTTL = this.storeConfigInfo.getStoreFileTtl();
> }
> if (filesToCompact.size() == 1) {
> // Single file
> HStoreFile sf = filesToCompact.iterator().next();
> OptionalLong minTimestamp = sf.getMinimumTimestamp();
> long oldest = minTimestamp.isPresent() ? now - minTimestamp.getAsLong() : Long.MIN_VALUE;
> if (sf.isMajorCompactionResult() && (cfTTL == Long.MAX_VALUE || oldest < cfTTL)) {
> float blockLocalityIndex =
> sf.getHDFSBlockDistribution().getBlockLocalityIndex(
> RSRpcServices.getHostname(comConf.conf, false));
> if (blockLocalityIndex < comConf.getMinLocalityToForceCompact()) {
> LOG.debug("Major compaction triggered on only store " + regionInfo
> + "; to make hdfs blocks local, current blockLocalityIndex is "
> + blockLocalityIndex + " (min " + comConf.getMinLocalityToForceCompact() + ")");
> result = true;
> } else {
> LOG.debug("Skipping major compaction of " + regionInfo
> + " because one (major) compacted file only, oldestTime " + oldest
> + "ms is < TTL=" + cfTTL + " and blockLocalityIndex is " + blockLocalityIndex
> + " (min " + comConf.getMinLocalityToForceCompact() + ")");
> }
> } else if (cfTTL != HConstants.FOREVER && oldest > cfTTL) {
> LOG.debug("Major compaction triggered on store " + regionInfo
> + ", because keyvalues outdated; time since last major compaction "
> + (now - lowTimestamp) + "ms");
> result = true;
> }
> } else {
> LOG.debug("Major compaction triggered on store " + regionInfo
> + "; time since last major compaction " + (now - lowTimestamp) + "ms");
> }
> result = true;
> }
> return result;
> }
> {code}
> {code}
> } else {
> LOG.debug("Major compaction triggered on store " + regionInfo
> + "; time since last major compaction " + (now - lowTimestamp) + "ms");
> }
> result = true;
> {code}
> if (lowTimestamp > 0L && lowTimestamp < (now - mcTime)), the result always equal true.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)