Skip to content

Commit e789f1a

Browse files
authored
Fix WAL throttle threshold fallback on hot reload (#18336) (#18514)
1 parent 3b83437 commit e789f1a

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

‎iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,6 +1798,11 @@ private void loadWALHotModifiedProps(TrimProperties properties) throws IOExcepti
17981798
}
17991799

18001800
long throttleDownThresholdInByte = Long.parseLong(getWalThrottleThreshold(properties));
1801+
if (throttleDownThresholdInByte < 0) {
1802+
throttleDownThresholdInByte =
1803+
Long.parseLong(
1804+
ConfigurationFileUtils.getConfigurationDefaultValue(DEFAULT_WAL_THRESHOLD_NAME[1]));
1805+
}
18011806
if (throttleDownThresholdInByte > 0) {
18021807
conf.setThrottleThreshold(throttleDownThresholdInByte);
18031808
}
@@ -2401,6 +2406,8 @@ private void overlayEffectiveConfigurationValues() {
24012406
Long.toString(commonDescriptor.getConfig().getSortBufferSize()));
24022407
ConfigurationFileUtils.updateAppliedProperties(
24032408
"mods_cache_size_limit_per_fi_in_bytes", Long.toString(conf.getModsCacheSizeLimitPerFI()));
2409+
ConfigurationFileUtils.updateAppliedProperties(
2410+
DEFAULT_WAL_THRESHOLD_NAME[1], Long.toString(conf.getThrottleThreshold()));
24042411
}
24052412

24062413
private void loadQuerySampleThroughput(TrimProperties properties) throws IOException {

‎iotdb-core/datanode/src/test/java/org/apache/iotdb/db/conf/PropertiesTest.java‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.apache.iotdb.db.conf;
2121

22+
import org.apache.iotdb.commons.conf.ConfigurationFileUtils;
2223
import org.apache.iotdb.commons.conf.TrimProperties;
2324
import org.apache.iotdb.commons.utils.RegionMigrationFileRemoveRateLimiter;
2425

@@ -36,6 +37,33 @@
3637
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses;
3738

3839
public class PropertiesTest {
40+
@Test
41+
public void testHotReloadNegativeWalThrottleThresholdUsesDefault() throws Exception {
42+
final String key = "wal_throttle_threshold_in_byte";
43+
final long configuredThreshold = 1024 * 1024 * 1024L;
44+
final long defaultThreshold =
45+
Long.parseLong(ConfigurationFileUtils.getConfigurationDefaultValue(key));
46+
final IoTDBDescriptor descriptor = IoTDBDescriptor.getInstance();
47+
final long originalThreshold = descriptor.getConfig().getThrottleThreshold();
48+
49+
try {
50+
final TrimProperties properties = new TrimProperties();
51+
properties.setProperty(key, Long.toString(configuredThreshold));
52+
descriptor.loadHotModifiedProps(properties);
53+
Assert.assertEquals(configuredThreshold, descriptor.getConfig().getThrottleThreshold());
54+
55+
properties.setProperty(key, "-1");
56+
descriptor.loadHotModifiedProps(properties);
57+
Assert.assertEquals(defaultThreshold, descriptor.getConfig().getThrottleThreshold());
58+
Assert.assertEquals(
59+
Long.toString(defaultThreshold), ConfigurationFileUtils.getAppliedProperties().get(key));
60+
} finally {
61+
final TrimProperties properties = new TrimProperties();
62+
properties.setProperty(key, Long.toString(originalThreshold));
63+
descriptor.loadHotModifiedProps(properties);
64+
}
65+
}
66+
3967
@Test
4068
public void testHotReloadRegionMigrationFileRemoveSpeedLimit() throws Exception {
4169
IoTDBDescriptor descriptor = IoTDBDescriptor.getInstance();

0 commit comments

Comments
 (0)