Skip to content

Validate database, Pipe, and Topic configuration - #19428

Open
Caideyipi wants to merge 7 commits into
apache:masterfrom
Caideyipi:config-validation-fallbacks
Open

Caideyipi wants to merge 7 commits into
apache:masterfrom
Caideyipi:config-validation-fallbacks

Conversation

@Caideyipi

Copy link
Copy Markdown
Collaborator

Summary

  • Validate database configuration values with warnings and default fallbacks.
  • Reject invalid Pipe and Topic parameters and report unknown keys without applying them.
  • Validate configuration on startup, reload, and cross-node parameter paths.
  • Preserve existing handling for unrelated configuration keys.

Example

For the aggregate processor, processor.output.max-delay-seconds=-1 remains the supported unlimited value, while -2 is rejected. Invalid database values fall back to the configured default with a warning.

Testing

  • spotless:apply -P with-integration-tests -pl iotdb-core/node-commons,iotdb-core/confignode,iotdb-core/datanode passed.
  • Focused module tests passed: 82 tests, 0 failures, 0 errors, 0 skipped.

if (reduced == null) {
return null;
}
switch (plugin) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/config/PipeParameterDefinitions.java:190 — Consensus-v2 connector attributes rejected: IOT_CONSENSUS_V2_ASYNC_CONNECTOR falls through to IOTDB_SINK

sinkDefinitions() has no case for IOT_CONSENSUS_V2_ASYNC_CONNECTOR/PIPE_CONSENSUS_ASYNC_CONNECTOR, so it returns IOTDB_SINK.get(reduced). RegionMaintainHandler.buildConsensusPipeReq sets connector.consensus.pipe-name, which is absent from iotdbSink(), so validateSink() throws PipeParameterNotValidException and consensus pipe creation (region migration / add peer) fails.

Fix: Add explicit cases for IOT_CONSENSUS_V2_ASYNC_CONNECTOR/PIPE_CONSENSUS_ASYNC_CONNECTOR (and _SINK) accepting consensus.group-id, consensus.pipe-name, ip/host/port, parallel.tasks, realtime-first, plus common sink keys.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the report. Common sink keys are resolved first, and consensus plugins fall through to IOTDB_SINK, which already defines the consensus and connection fields named here. I added regression coverage for the current and legacy connector/sink plugin names; no production change was needed for this case.

case DO_NOTHING_CONNECTOR:
case DO_NOTHING_SINK:
return null;
case SUBSCRIPTION_SINK:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/config/PipeParameterDefinitions.java:194 — subscription-sink rejects sink.topic / sink.consumer-group

SUBSCRIPTION_SINK only accepts reduced keys "topic" and "consumer-group", but SubscriptionSinkSubtaskManager reads PipeSinkConstant.SINK_TOPIC_KEY ("sink.topic") and SINK_CONSUMER_GROUP_KEY ("sink.consumer-group"). Any subscription pipe created with sink.topic/sink.consumer-group now fails validation with 'Ignoring unknown PIPE parameter'.

Fix: Accept both "topic"/"sink.topic" and "consumer-group"/"sink.consumer-group" (and connector.* aliases) for SUBSCRIPTION_SINK.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PipeParameters.KeyReducer removes the leading sink. or connector. prefix before lookup, so the existing topic and consumer-group definitions already accept all three forms. I added regression coverage for unprefixed, sink.*, and connector.* attributes; no production change was needed.

case RENAME_DATABASE_PROCESSOR:
known = reduced.equals("new-db-name");
break;
default:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

major iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/config/PipeParameterDefinitions.java:167 — standard-statistics-processor parameters are all rejected as unknown

processors() has no case for STANDARD_STATISTICS_PROCESSOR, so known is false for every key and validateProcessor() throws PipeParameterNotValidException for any attribute of that builtin processor (e.g. output.* keys it consumes), breaking pipes that use it.

Fix: Add a STANDARD_STATISTICS_PROCESSOR case mapping its supported keys (output.*, operators, windowing-strategy, etc.) to PROCESSOR definitions.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added STANDARD_STATISTICS_PROCESSOR to the aggregate-style whitelist for output.*, sliding.*, operators, and windowing-strategy parameters, with regression coverage.

properties.getProperty(
"max_sub_task_num_for_information_table_scan",
Integer.toString(conf.getMaxSubTaskNumForInformationTableScan())));
if (maxSubTaskNumForInformationTableScan > 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

major iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java:1351 — Removed overlayEffectiveConfigurationValues() leaves show configuration showing raw values

The overlay was deleted, but several keys still bypass ConfigValidation and are rewritten by setters: sort_buffer_size_in_bytes / mods_cache_size_limit_per_fi_in_bytes (loadFixedSizeLimitForQuery rewrites <=0), cte_buffer_size_in_bytes, max_rows_in_cte_buffer, max_sub_task_num_for_information_table_scan, mpp_data_exchange_max_payload_size_in_bytes, table_query_device_entry_batch_size_in_bytes, wal throttle threshold. For these, lastAppliedProperties now reports the raw file value instead of the
…[truncated]

Fix: Route these keys through ConfigValidation (or keep an explicit overlay) so the applied-properties map reflects the effective value.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored the effective-value overlay after startup loading and hot reload for the listed runtime-rewritten settings. The regression test verifies that the applied-properties map reports the effective values rather than the raw inputs.

@Caideyipi

Copy link
Copy Markdown
Collaborator Author

Review update summary

  • Reviewed PR head: d127bf01ab8c07c34f6fdfcd050abd59e2b82039.
  • Consensus sink mappings and subscription key aliases were already handled by the existing lookup/reducer paths; added regression coverage. Added the missing standard-statistics processor mapping and restored effective-value overlays for startup and hot reload.
  • Verification: Spotless passed for iotdb-core/node-commons and iotdb-core/datanode; focused tests passed (15 tests, 0 failures, 0 errors, 0 skipped).
  • Final local and remote source head: 28a8d725cb6fb0d0a7619515f61b862eda31a633 (confirmed). The PR remains open and non-draft.

config.setPipeHardlinkBaseDirName(
properties.getProperty("pipe_hardlink_base_dir_name", config.getPipeHardlinkBaseDirName()));
database(
properties,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

major iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/config/PipeDescriptor.java:64 — directory() rule rejects valid relative pipe hardlink dir names

pipe_hardlink_base_dir_name / pipe_hardlink_tsfile_dir_name are documented as relative directory names (e.g. pipe), but ConfigValidation.directory() only accepts values that Path.of can parse, so pipe is rejected and the configured value is silently replaced by the default with a warning. Previously any string was accepted.

Fix: Use a plain STRING definition (or a rule that only rejects blank/invalid characters) for these two keys instead of directory().

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The directory() rule uses Path.of to check syntax. Relative paths are accepted, and the path does not have to exist. I added a regression test that loads distinct relative values for both hardlink directory settings and checks they are retained. No production change was needed.

new Type<>(value -> BOOLEAN.parser().apply(value.trim()), "boolean"),
false,
unrestricted());
private static final Definition<String> MODE =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

major iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/subscription/meta/topic/TopicParameterDefinitions.java:60 — Topic mode/order-mode/format validated before normalization, rejecting previously valid values

MODE/ORDER_MODE/FORMAT parse with TopicConfig::normalizeMode/normalizeOrderMode (trim + lowercase + legacy live/consensus aliases) but the rule oneOf(true, ...) compares against the raw value, so mode=LIVE, mode=CONSENSUS, order-mode=LEADER_ONLY or format=RECORD_HANDLER now fail validation although TopicConfig.isValidMode/isValidOrderMode accept them.

Fix: Apply the same normalization inside the rule (e.g. matches(v -> TopicConfig.isValidMode(v), ...) / isValidOrderMode / case-insensitive format check) so validation matches TopicConfig semantics.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definition.parse() runs the type parser before applying the rule, so mode and order-mode are normalized before validation. The format allowlist compares case-insensitively. The regression test covers LIVE, CONSENSUS, LEADER-ONLY, and uppercase SubscriptionRecordHandler. LEADER_ONLY and RECORD_HANDLER are not existing configuration aliases. No production change was needed.

@Caideyipi
Caideyipi force-pushed the config-validation-fallbacks branch from 28a8d72 to fb27d58 Compare November 27, 2026 10:59
@Caideyipi

Copy link
Copy Markdown
Collaborator Author

Review and CI follow-up

  • Investigated the comments and CI failures at 28a8d725cb6fb0d0a7619515f61b862eda31a633; applied the test changes on top of source head fb27d5839dd4a90a89b5f6137c1959784c131e5c.
  • Added coverage for relative Pipe hardlink directory names, Topic mode normalization, and case-insensitive format matching. These already work without production changes.
  • Updated reload tests to check effective fallback values. Updated the tree and table Pipe tests to use source.realtime.mode, check that unknown ALTER attributes are dropped, and verify that out-of-range Zstd levels are rejected.
  • Local verification: Spotless and a focused Maven verify completed successfully with 29 unit tests and 8 Pipe integration tests (two 1C1D clusters), with no test failures, errors, or skips. The local RAT check was skipped due to the initialized Go submodule. The PropertiesTest fork logged a heap error during the run, but all 12 cases passed and Maven exited zero.
  • Final local commit, remote source branch, and PR head match: bb860e46cb0ea0592670dfd40f58207744f51cd5. The PR remains open and non-draft; GitHub CI for this update is separate from the local results.

if (defaultValue == null && hotReload && legacyKey != null) {
defaultValue = ConfigurationFileUtils.getConfigurationDefaultValue(legacyKey);
}
if (value == null && legacyValue == null && defaultValue == null) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

major iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/config/PipeDescriptor.java:893 — Hot reload resets pipe settings to template defaults when key is absent

loadExternal() no longer returns early when both value and legacyValue are null on hot reload; it resolves defaultValue from the template and calls the setter with it. Previously parserPipeConfig() returned null and the setter was skipped. Any set configuration that does not include e.g. pipe_sink_timeout_ms now overwrites the running value with the template default.

Fix: Restore the early return when value == null && legacyValue == null regardless of hotReload, so absent keys leave the current runtime value untouched.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9b0c01accf3. During hot reload, loadExternal() now returns immediately when both the primary and legacy values are absent, leaving the current runtime setting unchanged. Added regression coverage for the missing-key case.

final String value = properties.getProperty(key, null);
final String legacyValue = properties.getProperty(legacyKey, null);
final Definition<T> definition = new Definition<>(type, defaultValue, rule);
return value != null

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

major iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/ConfigValidation.java:274 — databaseAlias ignores legacy value when primary key is invalid

When the primary key is present but invalid, databaseAlias() falls back to defaultValue instead of the legacy key's value, and the warning names the primary key. E.g. default_database_level=abc with a valid default_storage_group_level=2 yields the built-in default 1 rather than 2, silently changing the effective database level.

Fix: On failure of the primary key, retry with the legacy value (databaseValue(properties, legacyKey, legacyValue, definition)) before falling back to defaultValue.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9b0c01accf3. When the primary value is invalid, databaseAlias() now validates the legacy value before falling back to the configured default, and records the effective value under the primary key. Added regression coverage for an invalid primary value with a valid legacy value.

.map(String::trim)
.mapToInt(Integer::parseInt)
.toArray();
long proportionSum = Arrays.stream(schemaMemoryProportion).asLongStream().sum();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/DataNodeMemoryConfig.java:347 — Zero-sum schema_memory_proportion now divides by zero

The previous code skipped applying the configured proportions when their sum was 0, keeping {5,4,1}. The new code computes proportionSum from the parsed values and divides by it unconditionally, so schema_memory_proportion=0:0:0 (previously accepted) throws ArithmeticException during startup.

Fix: Keep the old guard: if proportionSum == 0, fall back to the default {5,4,1} proportions (or reject the value in the weights rule).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The schema proportion definition already uses weights(3), whose validation requires a positive sum. Therefore 0:0:0 is rejected and databaseAlias() falls back to 5:4:1 before allocation, so the division-by-zero scenario is not reachable for this input. Added regression coverage confirming the default allocations; no production change was needed.

@Caideyipi
Caideyipi marked this pull request as draft November 30, 2026 02:14
@Caideyipi

Copy link
Copy Markdown
Collaborator Author

Review update summary

  • Reviewed candidate SHA: e83f5ac5fb45df9db749c08bb456ea056ddb3e6e.
  • Finding: extractor.consensus.group-id was incorrectly constrained to a non-negative integer, rejecting textual region IDs such as DataRegion[1] and preventing internal consensus-pipe creation.
  • Fix: the parameter is now validated as text; sender and receiver node IDs remain non-negative integers. Added a regression test.
  • Verification: Spotless passed; focused Maven tests passed (11 tests, 0 failures). Remote CI for the updated head is still running; WindowsScripts passed, while sonar and codecov were skipped.
  • Final local commit, source branch head, and PR head: 3f967f2604bf5f9287115eca72f23ab492d73aff (confirmed). PR remains a draft pending a fresh independent review of the updated head.

@Caideyipi

Copy link
Copy Markdown
Collaborator Author

Review update summary

  • Reviewed starting PR head: bb860e46cb0ea0592670dfd40f58207744f51cd5; rebased the comment fixes onto concurrent head 3f967f2604bf5f9287115eca72f23ab492d73aff.
  • Fixed hot reload so absent Pipe settings retain their current runtime values. Invalid primary configuration values now retry the legacy alias before using the default. Added regression coverage for both fixes and for zero-sum schema memory proportions; the existing weights(3) rule rejects a zero sum and falls back to 5:4:1, so no production change was needed for that report.
  • Verification: Spotless passed for node-commons and datanode; git diff --check passed. Focused Maven tests did not complete: the first attempt found an inaccessible constructor in the new test, and the corrected retry found a missing IOException declaration, now fixed. No further Maven run was made under the retry limit; all three new tests remain unverified.
  • Final local and confirmed remote source head: 9b0c01accf35f244455b0ed38579d4f0810c39ae. PR remains draft.

@Caideyipi
Caideyipi marked this pull request as ready for review November 30, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants