Skip to content

Commit 539e161

Browse files
committed
HBASE-26450 Server configuration will overwrite HStore configuration after using shell command 'update_config' (#3843)
Signed-off-by: Duo Zhang <zhangduo@apache.org> Signed-off-by: Baiqiang Zhao <zhaobaiqiang@apache.org>
1 parent 058d3a4 commit 539e161

2 files changed

Lines changed: 27 additions & 5 deletions

File tree

  • hbase-server/src

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,13 @@
5959
import org.apache.hadoop.hbase.Cell;
6060
import org.apache.hadoop.hbase.CellComparator;
6161
import org.apache.hadoop.hbase.CellUtil;
62-
import org.apache.hadoop.hbase.CompoundConfiguration;
6362
import org.apache.hadoop.hbase.HConstants;
6463
import org.apache.hadoop.hbase.MemoryCompactionPolicy;
6564
import org.apache.hadoop.hbase.TableName;
6665
import org.apache.hadoop.hbase.backup.FailedArchiveException;
6766
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
6867
import org.apache.hadoop.hbase.client.RegionInfo;
6968
import org.apache.hadoop.hbase.client.Scan;
70-
import org.apache.hadoop.hbase.client.TableDescriptor;
7169
import org.apache.hadoop.hbase.conf.ConfigurationManager;
7270
import org.apache.hadoop.hbase.conf.PropagatingConfigurationObserver;
7371
import org.apache.hadoop.hbase.coprocessor.ReadOnlyConfiguration;
@@ -2522,10 +2520,11 @@ protected OffPeakHours getOffPeakHours() {
25222520

25232521
@Override
25242522
public void onConfigurationChange(Configuration conf) {
2525-
this.conf = StoreUtils.createStoreConfiguration(conf, region.getTableDescriptor(),
2523+
Configuration storeConf = StoreUtils.createStoreConfiguration(conf, region.getTableDescriptor(),
25262524
getColumnFamilyDescriptor());
2527-
this.storeEngine.compactionPolicy.setConf(conf);
2528-
this.offPeakHours = OffPeakHours.getInstance(conf);
2525+
this.conf = storeConf;
2526+
this.storeEngine.compactionPolicy.setConf(storeConf);
2527+
this.offPeakHours = OffPeakHours.getInstance(storeConf);
25292528
}
25302529

25312530
/**

hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,6 +2141,29 @@ public void testFlattenSnapshotWriteCompactingMemeStoreConcurrently() throws Exc
21412141
}
21422142
}
21432143

2144+
@Test
2145+
public void testOnConfigurationChange() throws IOException {
2146+
final int COMMON_MAX_FILES_TO_COMPACT = 10;
2147+
final int NEW_COMMON_MAX_FILES_TO_COMPACT = 8;
2148+
final int STORE_MAX_FILES_TO_COMPACT = 6;
2149+
2150+
//Build a table that its maxFileToCompact different from common configuration.
2151+
Configuration conf = HBaseConfiguration.create();
2152+
conf.setInt(CompactionConfiguration.HBASE_HSTORE_COMPACTION_MAX_KEY,
2153+
COMMON_MAX_FILES_TO_COMPACT);
2154+
ColumnFamilyDescriptor hcd = ColumnFamilyDescriptorBuilder.newBuilder(family)
2155+
.setConfiguration(CompactionConfiguration.HBASE_HSTORE_COMPACTION_MAX_KEY,
2156+
String.valueOf(STORE_MAX_FILES_TO_COMPACT)).build();
2157+
init(this.name.getMethodName(), conf, hcd);
2158+
2159+
//After updating common configuration, the conf in HStore itself must not be changed.
2160+
conf.setInt(CompactionConfiguration.HBASE_HSTORE_COMPACTION_MAX_KEY,
2161+
NEW_COMMON_MAX_FILES_TO_COMPACT);
2162+
this.store.onConfigurationChange(conf);
2163+
assertEquals(STORE_MAX_FILES_TO_COMPACT,
2164+
store.getStoreEngine().getCompactionPolicy().getConf().getMaxFilesToCompact());
2165+
}
2166+
21442167
private HStoreFile mockStoreFileWithLength(long length) {
21452168
HStoreFile sf = mock(HStoreFile.class);
21462169
StoreFileReader sfr = mock(StoreFileReader.class);

0 commit comments

Comments
 (0)