HBASE-19767 Fix for Master web UI shows negative values for Remaining KVs
Negative Remaining KVs and progress percent greater than 100 is because CompactionProgress#totalCompactingKVs is sometimes less than CompactionProgress#currentCompactedKVs. Changes add a getter to CompactionProgress#totalCompactingKVs and from inside getter warning is logged. currentCompactedKVs are return when totalCompactingKVs are less than current. Signed-off-by: Michael Stack <stack@apache.org>
This commit is contained in:
parent
3434e99e6c
commit
8afa49f5d0
|
@ -1623,7 +1623,7 @@ public class HRegionServer extends HasThread implements
|
|||
storefileIndexSizeKB += store.getStorefilesRootLevelIndexSize() / 1024;
|
||||
CompactionProgress progress = store.getCompactionProgress();
|
||||
if (progress != null) {
|
||||
totalCompactingKVs += progress.totalCompactingKVs;
|
||||
totalCompactingKVs += progress.getTotalCompactingKVs();
|
||||
currentCompactedKVs += progress.currentCompactedKVs;
|
||||
}
|
||||
rootLevelIndexSizeKB += (int) (store.getStorefilesRootLevelIndexSize() / 1024);
|
||||
|
|
|
@ -1373,10 +1373,10 @@ public class HStore implements Store, HeapSize, StoreConfigInformation, Propagat
|
|||
writeCompactionWalRecord(filesToCompact, sfs);
|
||||
replaceStoreFiles(filesToCompact, sfs);
|
||||
if (cr.isMajor()) {
|
||||
majorCompactedCellsCount += getCompactionProgress().totalCompactingKVs;
|
||||
majorCompactedCellsCount += getCompactionProgress().getTotalCompactingKVs();
|
||||
majorCompactedCellsSize += getCompactionProgress().totalCompactedSize;
|
||||
} else {
|
||||
compactedCellsCount += getCompactionProgress().totalCompactingKVs;
|
||||
compactedCellsCount += getCompactionProgress().getTotalCompactingKVs();
|
||||
compactedCellsSize += getCompactionProgress().totalCompactedSize;
|
||||
}
|
||||
long outputBytes = getTotalSize(sfs);
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
package org.apache.hadoop.hbase.regionserver.compactions;
|
||||
|
||||
import org.apache.yetus.audience.InterfaceAudience;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* This class holds information relevant for tracking the progress of a
|
||||
|
@ -32,9 +34,10 @@ import org.apache.yetus.audience.InterfaceAudience;
|
|||
*/
|
||||
@InterfaceAudience.Private
|
||||
public class CompactionProgress {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CompactionProgress.class);
|
||||
|
||||
/** the total compacting key values in currently running compaction */
|
||||
public long totalCompactingKVs;
|
||||
private long totalCompactingKVs;
|
||||
/** the completed count of key values in currently running compaction */
|
||||
public long currentCompactedKVs = 0;
|
||||
/** the total size of data processed by the currently running compaction, in bytes */
|
||||
|
@ -51,7 +54,7 @@ public class CompactionProgress {
|
|||
* @return float
|
||||
*/
|
||||
public float getProgressPct() {
|
||||
return (float)currentCompactedKVs / totalCompactingKVs;
|
||||
return (float)currentCompactedKVs / getTotalCompactingKVs();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,7 +75,12 @@ public class CompactionProgress {
|
|||
/**
|
||||
* @return the total compacting key values in currently running compaction
|
||||
*/
|
||||
public long getTotalCompactingKvs() {
|
||||
public long getTotalCompactingKVs() {
|
||||
if (totalCompactingKVs < currentCompactedKVs) {
|
||||
LOG.warn("totalCompactingKVs={} less than currentCompactedKVs={}",
|
||||
totalCompactingKVs, currentCompactedKVs);
|
||||
return currentCompactedKVs;
|
||||
}
|
||||
return totalCompactingKVs;
|
||||
}
|
||||
|
||||
|
@ -92,7 +100,7 @@ public class CompactionProgress {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%d/%d (%.2f%%)", currentCompactedKVs, totalCompactingKVs,
|
||||
return String.format("%d/%d (%.2f%%)", currentCompactedKVs, getTotalCompactingKVs(),
|
||||
100 * getProgressPct());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ public class TestMajorCompaction {
|
|||
if( progress != null ) {
|
||||
++storeCount;
|
||||
assertTrue(progress.currentCompactedKVs > 0);
|
||||
assertTrue(progress.totalCompactingKVs > 0);
|
||||
assertTrue(progress.getTotalCompactingKVs() > 0);
|
||||
}
|
||||
assertTrue(storeCount > 0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue