在上一篇HBase Region操作实战分析之Mem Flush里,我从代码和日志层面介绍了region的memstore flush逻辑
在文章最后提到不断的flush会导致store目录下的storefile越来越多,则会触发region的(minor/major)compaction
配置项
hbase.hstore.compaction.max | 一次minor compaction的最大file数 |
hbase.hstore.compactionThreshold | 一次minor compaction的最小file数 |
hbase.hstore.blockingStoreFiles | file数超过此配置,则block flush |
我们知道,region进行flush,是因为region的memstoresize>hbase.hregion.memstore.flush.size 条件成立,引发region下所有store(cf)进行flush,在每个store进行flush时,会检测flush之后的文件数是否大于hbase.hstore.compactionThreshold(c-1),如果有一个store在flush时满足(c-1)条件,则在整个region flush完毕之后,会触发一次整个region的compaction.
代码如下:
for (StoreFlusher flusher : storeFlushers) {
boolean needsCompaction = flusher.commit();
if (needsCompaction) {
comp