From f391a2b8652c0c9e12ad9cf7d2ab672e955ff27e Mon Sep 17 00:00:00 2001 From: Baiqiang Zhao Date: Fri, 15 Jan 2021 14:00:50 +0800 Subject: [PATCH] HBASE-25431 MAX_FILESIZE and MEMSTORE_FLUSHSIZE should not be set negative number (#2803) Signed-off-by: stack --- .../hbase/util/TableDescriptorChecker.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/TableDescriptorChecker.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/TableDescriptorChecker.java index c69d38a8ec2..30c07b325a1 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/TableDescriptorChecker.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/TableDescriptorChecker.java @@ -27,6 +27,7 @@ import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; import org.apache.hadoop.hbase.client.TableDescriptor; +import org.apache.hadoop.hbase.client.TableDescriptorBuilder; import org.apache.hadoop.hbase.regionserver.DefaultStoreEngine; import org.apache.hadoop.hbase.regionserver.HStore; import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost; @@ -82,10 +83,11 @@ public final class TableDescriptorChecker { // check max file size long maxFileSizeLowerLimit = 2 * 1024 * 1024L; // 2M is the default lower limit - long maxFileSize = td.getMaxFileSize(); - if (maxFileSize < 0) { - maxFileSize = conf.getLong(HConstants.HREGION_MAX_FILESIZE, maxFileSizeLowerLimit); - } + // if not set MAX_FILESIZE in TableDescriptor, and not set HREGION_MAX_FILESIZE in + // hbase-site.xml, use maxFileSizeLowerLimit instead to skip this check + long maxFileSize = td.getValue(TableDescriptorBuilder.MAX_FILESIZE) == null ? + conf.getLong(HConstants.HREGION_MAX_FILESIZE, maxFileSizeLowerLimit) : + Long.parseLong(td.getValue(TableDescriptorBuilder.MAX_FILESIZE)); if (maxFileSize < conf.getLong("hbase.hregion.max.filesize.limit", maxFileSizeLowerLimit)) { String message = "MAX_FILESIZE for table descriptor or " + "\"hbase.hregion.max.filesize\" (" + @@ -96,10 +98,11 @@ public final class TableDescriptorChecker { // check flush size long flushSizeLowerLimit = 1024 * 1024L; // 1M is the default lower limit - long flushSize = td.getMemStoreFlushSize(); - if (flushSize < 0) { - flushSize = conf.getLong(HConstants.HREGION_MEMSTORE_FLUSH_SIZE, flushSizeLowerLimit); - } + // if not set MEMSTORE_FLUSHSIZE in TableDescriptor, and not set HREGION_MEMSTORE_FLUSH_SIZE in + // hbase-site.xml, use flushSizeLowerLimit instead to skip this check + long flushSize = td.getValue(TableDescriptorBuilder.MEMSTORE_FLUSHSIZE) == null ? + conf.getLong(HConstants.HREGION_MEMSTORE_FLUSH_SIZE, flushSizeLowerLimit) : + Long.parseLong(td.getValue(TableDescriptorBuilder.MEMSTORE_FLUSHSIZE)); if (flushSize < conf.getLong("hbase.hregion.memstore.flush.size.limit", flushSizeLowerLimit)) { String message = "MEMSTORE_FLUSHSIZE for table descriptor or " + "\"hbase.hregion.memstore.flush.size\" (" + flushSize +