HTHou commented on code in PR #18569:
URL: https://github.com/apache/iotdb/pull/18569#discussion_r3912355484


##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/audit/AbstractAuditLogger.java:
##########
@@ -136,4 +138,46 @@ public void recordTrustedChannelFailureAuditLogIfNecessary(
       RECORDING_TRUSTED_CHANNEL_FAILURE.remove();
     }
   }
+
+  /** Records one user-data transfer attempt without retaining any transferred 
payload. */
+  public void recordUserDataTransferAuditLog(UserDataTransferAuditEvent event) 
{
+    if (!IS_AUDIT_LOG_ENABLED
+        || event == null
+        || event.getInitiator() == null
+        || event.getSource() == null
+        || event.getTarget() == null
+        || Boolean.TRUE.equals(RECORDING_USER_DATA_TRANSFER.get())) {
+      return;
+    }
+
+    final String initiatorIdentifier = 
NodeUrlUtils.convertTEndPointUrl(event.getInitiator());
+    final String sourceIdentifier = 
NodeUrlUtils.convertTEndPointUrl(event.getSource());
+    final String targetIdentifier = 
NodeUrlUtils.convertTEndPointUrl(event.getTarget());
+    RECORDING_USER_DATA_TRANSFER.set(true);
+    try {
+      log(
+          new AuditLogFields(
+              INTERNAL_AUDIT_LOG_USER_ID,
+              User.BUILTIN_INTERNAL_AUDIT_LOG_USERNAME,
+              initiatorIdentifier,
+              AuditEventType.USER_DATA_TRANSFER,
+              null,

Review Comment:
   [P1] In TimechoDB, the concrete noNeedInsertAuditLog implementation checks 
AuditLogOperation before the event type. Passing null here makes 
auditableOperationType.contains(operation) false, so every USER_DATA_TRANSFER 
event is filtered out before persistence. Please assign a real operation 
category (for example CONTROL), add USER_DATA_TRANSFER to the corresponding 
auditable event-type list, and cover the concrete filtering path with a test.



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/source/SourceHandle.java:
##########
@@ -637,11 +644,19 @@ public void run() {
           attempt += 1;
 
           long startTime = System.nanoTime();
+          boolean transferAttemptRecorded = false;
           try (SyncDataNodeMPPDataExchangeServiceClient client =
               
mppDataExchangeServiceClientManager.borrowClient(remoteEndpoint)) {
             TGetDataBlockResponse resp = client.getDataBlock(req);
             int tsBlockNum = resp.getTsBlocks().size();
-            if (tsBlockNum == 0) {
+            if (tsBlockNum != endSequenceId - startSequenceId) {

Review Comment:
   [P1] This mismatch branch now returns immediately. For a non-empty short 
response, the previous code would throw at tsBlocks.get(...) and enter the 
existing retry loop; the new path exits without filling sequenceIdToTsBlock and 
without completing or failing blocked, so the query may wait indefinitely. 
Please record UNEXPECTED_RESPONSE_SIZE once and then preserve the retry/fail 
behavior, for example by throwing into the existing catch path. A 
short-response regression test would catch this.



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/DataRegionConsensusImpl.java:
##########
@@ -143,6 +145,11 @@ private static ConsensusConfig buildConsensusConfig() {
           .setThisNode(new TEndPoint(CONF.getInternalAddress(), 
CONF.getDataRegionConsensusPort()))
           .setTrustedChannelFailureHandler(
               
DNAuditLogger.getInstance()::recordTrustedChannelFailureAuditLogIfNecessary)
+          .setUserDataTransferAuditHandler(
+              COMMON_CONF.isEnableAuditLog()
+                  ? DNAuditLogger.getInstance()::recordUserDataTransferAuditLog
+                  : UserDataTransferAuditHandler.NO_OP)
+          
.setUserDataTransferAuditClassifier(DataNodeUserDataTransferAuditor::containsUserData)

Review Comment:
   [P2] The audit handler is configured as NO_OP when auditing is disabled, but 
this classifier is still installed unconditionally. As a result, the default 
audit-disabled path still resolves the DataRegion and traverses every request; 
WAL and remote IoTConsensus requests are additionally deserialized solely for 
classification. Please configure NO_USER_DATA under the same audit-enabled 
condition, or add an equivalent early gate before any lookup/deserialization.



##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/audit/UserDataTransferProtectionMethod.java:
##########
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons.audit;
+
+public enum UserDataTransferProtectionMethod {
+  TLS,
+  UNPROTECTED;

Review Comment:
   [P3] The agreed minimum schema uses protection_method values TLS and NONE, 
while this enum emits UNPROTECTED. Since this API is new, please rename the 
value to NONE now so the persisted audit value matches the documented schema.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to