Skip to content

Backport #19468 to dev/1.3 - #19474

Open
Caideyipi wants to merge 6 commits into
apache:dev/1.3from
Caideyipi:codex/cp-21612-dev13
Open

Caideyipi wants to merge 6 commits into
apache:dev/1.3from
Caideyipi:codex/cp-21612-dev13

Conversation

@Caideyipi

@Caideyipi Caideyipi commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Backports commit 21612f0e61f98cd5c6c77b3dd89270f5f09b2776 to dev/1.3.

This change keeps sink metric names and tags independent of connector attributes, sanitizes sink subtask display IDs and error output, and adds regression coverage for hidden attributes and subscription sink metric names.

.recordPipeResourceFailure(event.getPipeName(), event.getCreationTime(), failureType);
}

public String getDisplayTaskID() {

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/pipe/agent/task/subtask/sink/PipeSinkSubtask.java:688 — getDisplayTaskID() is never wired into error output; new test fails and raw taskID still leaks attributes

PipeSinkSubtask.getDisplayTaskID() is dead code: PipeAbstractSinkSubtask.handleException (line 370) and transferHeartbeatEvent still format the raw taskID, which embeds attributeSortedString (e.g. sink.password=..., sink.token=...). testTransferExceptionUsesDisplayTaskID (PipeSinkSubtaskTest:187) asserts the message contains "Exception in pipe transfer, subtask: sink_", so it fails at head while credentials remain in pipe exception messages.

Fix: Backport the node-commons part: add an overridable getDisplayTaskID() on PipeAbstractSinkSubtask and use it in handleException and transferHeartbeatEvent instead of taskID.

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.

Confirmed and fixed. PipeAbstractSinkSubtask.handleException() uses getDisplayTaskID(), and heartbeat connector failures now use the same sanitized ID. Added testHeartbeatTransferExceptionUsesDisplayTaskID, which checks the exception cause chain; the focused suite passes (23 tests).


Assert.assertFalse(displayString.contains("plain-text-password"));
Assert.assertFalse(displayString.contains("plain-text-connector-password"));
Assert.assertFalse(displayString.contains("plain-text-key-store-password"));

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/test/java/org/apache/iotdb/db/pipe/agent/task/subtask/sink/PipeSinkSubtaskManagerTest.java:159 — testGenerateAttributeDisplayStringHidesSensitiveAttributes fails: ssl.key-store-pwd is not a hidden key

PipeParameters.ValueHider.KEYS contains only "ssl.trust-store-pwd" and "password", so generateAttributeDisplayString emits "{sink.ssl.key-store-pwd=plain-text-key-store-password, sink.user=root}". The new assertions at line 159 (no "plain-text-key-store-password") and line 162 (no "sink.ssl.key-store-pwd") therefore fail.

Fix: Add "ssl.key-store-pwd" to ValueHider.KEYS, or change the test to use sink.ssl.trust-store-pwd, which is the only SSL password key IoTDB actually hides.

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.

Confirmed: ssl.key-store-pwd is included in the hidden-key set, and key matching is case-normalized. testGenerateAttributeDisplayStringHidesSensitiveAttributes asserts neither the key nor its plaintext value is displayed; the focused suite passes (23 tests).

@Caideyipi
Caideyipi marked this pull request as draft December 2, 2026 02:22
@Caideyipi
Caideyipi marked this pull request as ready for review December 2, 2026 02:39
@Caideyipi

Copy link
Copy Markdown
Collaborator Author

Fixed the two failing Windows DataNode tests:

  • Pipe transfer exceptions now use the sink display task ID instead of the raw task ID, which may contain connector attributes.
  • ssl.key-store-pwd is now excluded from displayed connector attributes.

Verification: Spotless passed, and the focused DataNode test run passed (22 tests, 0 failures).

Failure analyzed at PR head adbb77344b1a290eb320494f6799d38051a23b20; final local and confirmed PR/source head: 0bc9b708ffdae888cabb862fb4111bd450b2e26b.

@luoluoyuyu

Copy link
Copy Markdown
Member

minor iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/agent/task/subtask/sink/PipeSinkSubtask.java:387 — Sink subtask close/discard logs still print raw taskID with plaintext connector credentials

close() logs the raw taskID at INFO (387, 394), and discardPendingEventsOfPipeUnderLock (361), the "PipeSinkSubtaskClose-" thread name (433) and the close-timeout warn (454) do the same. taskID embeds attributeSortedString (e.g. sink.password=..., sink.token=...), so every sink subtask close writes plaintext credentials to datanode.log; the same PR removed that raw string from PipeSinkSubtaskManager's register log.

Fix: Replace taskID with getDisplayTaskID() in these LOGGER calls and in the "PipeSinkSubtaskClose-" thread name, matching the upstream commit.

@Caideyipi

Copy link
Copy Markdown
Collaborator Author

@luoluoyuyu Fixed. Close success/failure logs, pending-event discard warnings, the close-thread name, and the timeout warning now use getDisplayTaskID(). Heartbeat failures and handshake-retry warnings are sanitized too; metric identifiers remain unchanged.

@Caideyipi

Copy link
Copy Markdown
Collaborator Author

Follow-up summary:

  • Replaced raw IDs in heartbeat/handshake errors and close/discard diagnostics with getDisplayTaskID(); metric identity remains unchanged.
  • Confirmed the ssl.key-store-pwd redaction and shared exception formatting; added heartbeat exception cause-chain regression coverage.
  • Verification: mvn spotless:apply -P with-integration-tests -pl iotdb-core/datanode,iotdb-core/node-commons passed; clean DataNode reactor tests passed (23 tests, 0 failures or errors).
  • Reviewed head: 0bc9b708ffdae888cabb862fb4111bd450b2e26b. Commit: 781a046403df02c3ae27f120922203a7bc5f9ee9; local, source-branch, and PR heads all match.

@luoluoyuyu

Copy link
Copy Markdown
Member

minor iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/metric/sink/PipeDataRegionSinkMetrics.java:361 — Sink metric logs still print raw taskID containing plaintext connector credentials

deregister (361), markTabletEvent (378) and markTsFileEvent (392) log the raw taskID, as do PipeSchemaRegionSinkMetrics.deregister (187) and markSchemaEvent (205). taskID = pipeName + "" + attributeSortedString + "" + creationTime + "_" + index, so it embeds sink.password/sink.token in plaintext. Trigger: MetricService.restartService() calls unbindFrom, which deregisters every entry from connectorMap, so later subtask close() hits the warn branch and every event hits the INFO branch, writing credentials to datanode.log.

Fix: Log a sanitized identifier (e.g. getMetricName() plus pipe/region tags) instead of the raw taskID in these branches, keeping taskID only as the internal map key.

@Caideyipi

Copy link
Copy Markdown
Collaborator Author

@luoluoyuyu Fixed in 83c45a8. The missing-entry branches no longer include taskID; because the subtask is absent from connectorMap, no per-subtask sanitized tags are available, so the diagnostic now uses the stable sink metric name only. This covers data-region deregistration/tablet/TsFile events and schema-region deregistration/schema events. Added regression tests asserting the logged messages omit the task ID and password value. The focused tests pass (6 tests, 0 failures).

@Caideyipi

Copy link
Copy Markdown
Collaborator Author

Review update for head 781a046403df02c3ae27f120922203a7bc5f9ee9:

  • Finding: missing-entry sink metric logs could expose raw task IDs containing connector credentials.
  • Fix: replaced raw IDs with a stable sink metric name in the affected data-region and schema-region logs, and added regression coverage for all five affected paths.
  • Verification: mvn spotless:apply -pl iotdb-core/datanode passed. mvn clean test -pl iotdb-core/datanode -am '-Dtest=PipeDataRegionSinkMetricsTest,PipeSchemaRegionSinkMetricsTest' '-Dsurefire.failIfNoSpecifiedTests=false' passed (6 tests, 0 failures).
  • Final local, source-branch, and PR head: 83c45a8c791a3b6119e18b918a93c6f0a4381796.

@luoluoyuyu

Copy link
Copy Markdown
Member

major iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/agent/task/subtask/PipeReportableSubtask.java:130 — Sink failure/retry logs still print raw taskID with plaintext connector credentials

onReportEventFailure (116, 130, 141, 154, 171) and onNonReportEventFailure (187, 198, 209) log the raw taskID at WARN. For sink subtasks taskID = pipeName_{...sink.password=<plaintext>...}_creationTime_index, so every sink transfer failure and every locally-retried connection error (PipeAbstractSinkSubtask.onFailure -> super.onFailure) writes credentials to datanode.log; PipeSubtask.onSuccess:119 logs it again after a successful retry.

Fix: Add a public getDisplayTaskID() on PipeSubtask (default getTaskID) and log it here and in PipeSubtask.onSuccess instead of taskID, as done on master.

@luoluoyuyu

Copy link
Copy Markdown
Member

minor iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/agent/task/execution/PipeSubtaskExecutor.java:161 — Sink subtask start/close logs still print raw taskID with plaintext credentials

start() logs "The subtask {} is started to submit self." (138) and deregister() logs "The subtask {} is closed successfully." / the close error (161, 163) with the raw subTaskID. PipeSinkSubtaskLifeCycle passes subtask.getTaskID(), which embeds attributeSortedString (sink.password/sink.token), so every sink subtask start and close writes plaintext credentials at INFO to datanode.log, immediately after the now-sanitized PipeSinkSubtask.close() log.

Fix: Log the subtask display ID (e.g. subtask.getDisplayTaskID(), exposing it publicly on PipeSubtask) instead of the raw subTaskID in register/start/stop/deregister.

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