Skip to content

[To dev/1.3] Normalize topic and pipe attributes - #19476

Open
Caideyipi wants to merge 11 commits into
apache:dev/1.3from
Caideyipi:cp-19418-dev-1.3
Open

Caideyipi wants to merge 11 commits into
apache:dev/1.3from
Caideyipi:cp-19418-dev-1.3

Conversation

@Caideyipi

Copy link
Copy Markdown
Collaborator

Summary

Backports the Topic and Pipe attribute-normalization behavior from #19418 that applies to the 1.3 branch. Built-in Topic property keys are canonicalized case-insensitively and their values are trimmed, while extension attributes remain unchanged. Built-in Pipe plugin names and parameter keys are normalized; eligible values are normalized without changing path, credential, identifier, and other case-sensitive values. Custom-plugin attributes remain untouched.

Normalization is applied during Topic creation and metadata recovery, and throughout Pipe validation, metadata recovery, and task initialization. Partial ALTER PIPE updates retain unspecified attributes; REPLACE ALL continues to use only the replacement attributes.

This backport omits master-only double-living Pipe logic and table-model Topic behavior, which have no applicable counterpart in dev/1.3.

Examples

  • Topic input: {" PATH ": " Root.SG.** ", " Extension.Option ": " Mixed Value "}. Stored attributes: {"path": "Root.SG.**", " Extension.Option ": " Mixed Value "}.
  • Built-in Pipe input: {" SOURCE ": " IOTDB-EXTRACTOR ", " Source.Path ": " Root.SG.** ", " Source.Mode ": " QUERY "}. Normalized attributes include source=iotdb-extractor, source.path= Root.SG.** , and source.mode=query; the path value retains its case and surrounding spaces.

Source

Backport of #19418, commits 9503c1d35a74b73f1453fbfec45b6fa8d4189e6b, a5551d07bd10d7b13f01f3480e1261b3a1dd23ff, and 8d42f1ccb4d31d25c09973e0209c4d216c120fa1.

Validation

  • Spotless passed.
  • 27 targeted tests passed with no failures, errors, or skips.
  • Full-reactor mvn test-compile -DskipTests passed.
  • Full-reactor mvn test-compile -P with-zh-locale -DskipTests passed.
  • git diff --check passed.

@Caideyipi

Copy link
Copy Markdown
Collaborator Author

Initial CP self-review summary for candidate f1c17c292c0fee1a956234152e5082cd066659ef (reviewed, final local, and confirmed remote head):

  • Scope: backports the 1.3-applicable Topic/Pipe attribute normalization from Normalize case and whitespace in topic and pipe attributes #19418 and omits master-only behavior without a 1.3 counterpart.
  • Finding fixed: a custom-plugin test looked up the original whitespace-padded selector key after normalization; the assertion now uses the canonical source key.
  • Verification: Spotless passed; 27 targeted tests passed; full-reactor English and Chinese test-compile passed; git diff --check passed.
  • Source commits: 9503c1d35a74b73f1453fbfec45b6fa8d4189e6b, a5551d07bd10d7b13f01f3480e1261b3a1dd23ff, and 8d42f1ccb4d31d25c09973e0209c4d216c120fa1.

@Caideyipi

Copy link
Copy Markdown
Collaborator Author

Follow-up for the current head 0ac0ec7b1cf6c184d17108c7687fd5465c8c4e39 (reviewed head: f1c17c292c0fee1a956234152e5082cd066659ef; final local and confirmed remote head: 0ac0ec7b1cf6c184d17108c7687fd5465c8c4e39).

  • Findings fixed: normalized pipe-attribute collisions now fail deterministically with PipeException; built-in write-back sink database values preserve case, fixing the reported tree-model target-database regression.
  • Regression coverage: added tests for both behaviors.
  • Verification: Spotless and the two focused normalization tests pass; focused node-commons compile/test-compile passes for English and Chinese locales. Full-reactor English test-compile is blocked in iotdb-thrift-commons by the unavailable preallocSize(int) API in this local build environment; the full Chinese reactor compile was not completed. The reported integration-test failure was diagnosed from CI logs but not rerun locally.
  • The PR remains open. No checks are reported yet for the updated head.

@luoluoyuyu

Copy link
Copy Markdown
Member

major iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/pipe/task/CreatePipeProcedureV2.java:146 — ConfigNode create-pipe auth check reads raw attributes, bypassed by normalized key variants

CREATE PIPE with variants like 'Source.Username'/'SOURCE.PASSWORD' is normalized by PipeStaticMeta so these keys take effect at runtime, but executeFromValidateTask passes the raw map to checkAndEnrichSourceAuthentication, which uses exact/prefix-only lookups. login4Pipe is skipped, so the password is never validated and the plaintext is stored instead of the hashed value.

Fix: Normalize extractorAttributes with PipePluginAgent.normalizeSourceParameters before checkAndEnrichSourceAuthentication/checkPipePluginExistence, or make their key lookups trim- and case-insensitive.

@luoluoyuyu

Copy link
Copy Markdown
Member

minor iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/pipe/PipeFunctionSupport.java:55 — now is never substituted for normalized source start/end-time key variants

applyNowFunctionToExtractorAttributes runs before normalization and reads only exact keys, so CREATE PIPE with ' SOURCE.START-TIME'='now' is not substituted. Normalization then yields source.start-time=now, and PipeHistoricalDataRegionTsFileSource/PipeRealtimeDataRegionSource throw PipeParameterNotValidException parsing it, so this newly accepted key form cannot use the documented now value.

Fix: Apply the now substitution after attribute normalization, or resolve start/end-time keys with the same trim/case-insensitive lookup used by normalization.

@Caideyipi

Copy link
Copy Markdown
Collaborator Author

Follow-up to review comments #7335373236 and #7335373522. Reviewed head: 0ac0ec7b1cf6c184d17108c7687fd5465c8c4e39; final local and confirmed remote head: 538cd8f167b4d78029b0c0c1b485e17c82a17534.

  • Fixed the source-authentication bypass: ConfigNode now normalizes extractor attributes before plugin validation and authentication. Case/space variants therefore reach login4Pipe, and persisted metadata receives the hashed credential.
  • Fixed now substitution for time-key variants by matching trimmed, case-insensitive source/extractor keys.
  • Synced the PR branch with dev/1.3 at 450e3158fea7eae8e8b930db84fa7a2409403960; the PipeStaticMeta conflict resolution retains both normalization and completion-support initialization.
  • Local verification: Spotless passed; focused clean reactor tests passed (7 tests, 0 failures); git diff --check passed.
  • Remote CI for this head is queued/running; no CI pass is claimed.

@Caideyipi

Caideyipi commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Fixed in 538cd8f167b4d78029b0c0c1b485e17c82a17534. executeFromValidateTask now normalizes extractor attributes before plugin validation and authentication, so case- and whitespace-variant username/password keys reach login4Pipe and the stored password is hashed. Added testValidateNormalizesSourceAttributesBeforeAuthentication.

@Caideyipi

Caideyipi commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Fixed in 538cd8f167b4d78029b0c0c1b485e17c82a17534. PipeFunctionSupport now resolves time attributes with trimmed, case-insensitive key matching before replacing now, including variants such as SOURCE.START-TIME. Added testApplyNowFunctionToNormalizedSourceKeyVariant.

@Caideyipi

Caideyipi commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Comment-handling follow-up for reviewed head 538cd8f167b4d78029b0c0c1b485e17c82a17534; final local and confirmed remote head: 4672a04f96a55b9dd50088848ea4d0f6267d34f1.

  • Fixed in the final head: preserve case-sensitive consensus.group-id; allow legacy duplicate built-in keys during deserialization by keeping the first serialized occurrence, while retaining strict rejection for DDL and updates.
  • Already fixed in the reviewed head: normalize source attributes before authentication and resolve now with trimmed, case-insensitive time-key matching.
  • Verification: Spotless passed; the two focused Node Commons test classes passed (10 tests); git diff --check passed. ConfigNode and DataNode regression tests from the reviewed head were not rerun locally in this round due to limited available memory.

if (entry.getKey() != null
&& pluginNameKey.equalsIgnoreCase(entry.getKey().trim())
&& entry.getValue() != null) {
return entry.getValue();

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/node-commons/src/main/java/org/apache/iotdb/commons/pipe/agent/plugin/PipePluginAgent.java:317 — Blank plugin-name value silently disables normalization for the plugin's other attributes

getPluginName only skips null values, so a whitespace-only plugin value such as 'CONNECTOR'=' ' is returned as the plugin name; isBuiltinPlugin then returns false and normalizePluginParameters takes the custom-plugin branch, leaving every other attribute with its padded/mixed-case key and skipping duplicate-key rejection. PipeSinkConstant.getConnectorOrSinkNameWithDefault ignores blank values and falls back to iotdb-thrift-connector, so the pipe runs with the default built-in connector while ' Connector.Node-URLs ' / ' CONNECTOR.USER ' are never applied.

Fix: Ignore blank values in getPluginName (skip entries whose value trim() is empty) so such pipes resolve through the defaultPluginName path computed by normalizeSinkParameters and get normalized as the built-in plugin they actually run as.

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 922999a0b4574243a8bd6b4b8036504390857c78. getPluginName now skips whitespace-only plugin-name values so blank connector names fall through to the default built-in connector, allowing padded keys such as Connector.Node-URLs to be normalized. Added testNormalizeSinkParametersWithBlankConnectorName.

@Caideyipi

Copy link
Copy Markdown
Collaborator Author

Comment-handling update for reviewed head 4672a04f96a55b9dd50088848ea4d0f6267d34f1; final local and confirmed remote head: 922999a0b4574243a8bd6b4b8036504390857c78.

  • Fixed blank plugin-name handling so sink normalization falls back to the default built-in connector and normalizes padded attributes.
  • Verification: Spotless passed; the focused node-commons reactor test passed across 21 modules. PipePluginAgentNormalizationTest reported 4 passing tests in both Surefire executions, with 0 failures, errors, or skips. git diff --check passed.
  • The PR remains open and non-draft. No CI result is claimed for the new head.

private final PipeProcessorConstructor pipeProcessorConstructor;
private final PipeSinkConstructor pipeSinkConstructor;

private static final Set<String> PARAMETER_VALUE_PRESERVATION_KEYS =

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/agent/plugin/PipePluginAgent.java:63 — Value case-folding lowercases 'Z' in start-time/end-time, breaking pipe creation

Built-in values absent from PARAMETER_VALUE_PRESERVATION_KEYS are folded to trim+lowercase, but start-time/end-time (incl. history.*) are missing, so 'source.start-time'='2024-01-01T00:00:00Z' is stored and validated as '2024-01-01t00:00:00z'. DateTimeUtils.convertDatetimeStrToLong only recognizes uppercase 'Z', so it appends a zone offset and then fails to parse; PipeHistoricalDataRegionTsFileSource/PipeRealtimeDataRegionSource.validate throw PipeParameterNotValidException and CREATE/ALTER PIPE fails.

Fix: Add start-time, end-time, history.start-time, history.end-time (and processor sliding.boundary-time) to PARAMETER_VALUE_PRESERVATION_KEYS, or skip value case-folding for timestamp-valued attributes.

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 27fe3f2c0fe7ca1418477856b956daa3bd1e73c8. The normalization allowlist now preserves values for start-time, end-time, history.start-time, history.end-time, and sliding.boundary-time, so ISO-8601 timestamps retain uppercase T and Z. Added regression coverage for these source and processor parameters. PipePluginAgentNormalizationTest passes (5 tests).

@Caideyipi

Copy link
Copy Markdown
Collaborator Author

Comment-handling round for reviewed head 922999a0b4574243a8bd6b4b8036504390857c78; final local and confirmed remote head: 27fe3f2c0fe7ca1418477856b956daa3bd1e73c8.

  • Fixed timestamp value case-folding for source start/end and history parameters, plus sliding.boundary-time, preserving uppercase T/Z.
  • Added regression coverage for all five normalized keys.
  • Verification: Spotless passed; PipePluginAgentNormalizationTest passed (5 tests); git diff --check passed.
  • The PR remains open and non-draft. Remote CI was not checked.

public SettableFuture<ConfigTaskResult> createPipe(
final CreatePipeStatement createPipeStatement) {
if (!PipeDataNodeAgent.isPipeDataInsertionEnabled(createPipeStatement.getSourceAttributes())) {
final PipeParameters sourcePipeParameters =

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/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java:1849 — Duplicate-key PipeException escapes as INTERNAL_SERVER_ERROR instead of PIPE_ERROR

createPipe (1849) and alterPipe (2074) call the new strict PipePluginAgent.normalizeSourceParameters* outside any try/catch, while every other failure in these methods is converted to IoTDBException(..., TSStatusCode.PIPE_ERROR). CREATE/ALTER PIPE with trim/case variants of one built-in key (e.g. 'source.path' and ' SOURCE.PATH ') now throws a raw PipeException there; ConfigExecution.fail() maps non-IoTDBException to INTERNAL_SERVER_ERROR, so the duplicate-key rejection is reported with a 500 code instead of the pipe error code.

Fix: Move the normalize calls into the existing validation try blocks (or catch PipeException around them) and use future.setException(new IoTDBException(msg, TSStatusCode.PIPE_ERROR.getStatusCode())), as done for validate/validateSink failures.

@Caideyipi Caideyipi Dec 4, 2026 •

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 1c66671b6b21d66fe27dc8199f59ca01e6db8a3d. CREATE PIPE now maps duplicate-key normalization failures to PIPE_ERROR; ALTER PIPE performs normalization inside its existing validation handler, which maps the same failure to PIPE_ERROR. Added a CREATE regression test asserting the returned error code; the ALTER path was verified against the existing validation flow.

@Caideyipi

Caideyipi commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator Author

Follow-up to the source-authentication finding: the current head normalizes source attributes before plugin checks and authentication, so trimmed, case-insensitive username/password aliases reach the validation and hashing path. No additional change was needed for this finding.

@Caideyipi

Caideyipi commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator Author

Follow-up to the now substitution finding: the current head resolves source-time keys after trimming and case-insensitive comparison before substituting now. No additional change was needed for this finding.

@Caideyipi

Copy link
Copy Markdown
Collaborator Author

Review round update for PR #19476 (CP targeting dev/1.3):

  • Reviewed starting head: 27fe3f2c0fe7ca1418477856b956daa3bd1e73c8.
  • Fixed the duplicate-normalized-key error mapping: CREATE PIPE returns PIPE_ERROR for normalization collisions, and ALTER PIPE performs source normalization inside its existing validation handler so the same failure is mapped to PIPE_ERROR.
  • Added a CREATE regression test asserting the error code. The earlier source-authentication and now-alias findings are also addressed in this branch; follow-ups were added to both comments.
  • Verification: Spotless passed; the clean focused DataNode reactor test passed (1 test, 0 failures/errors); commit whitespace check passed.
  • Final local and confirmed PR head: 1c66671b6b21d66fe27dc8199f59ca01e6db8a3d. PR remains open and non-draft.

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