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


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/exchange/source/SourceHandle.java:
##########
@@ -654,6 +666,8 @@ public void run() {
               }
               return;
             }
+            recordTransferAttempt(attempt, true, null, null);

Review Comment:
   Addressed in 43a7104b17. SourceHandle now requires the response block count 
to exactly match the requested sequence range and records success only after 
every block is accepted into the local buffer. Empty/mismatched responses and a 
closed receiver are recorded as failures.



##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/audit/UserDataTransferAuditEvent.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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;
+
+import org.apache.iotdb.common.rpc.thrift.TEndPoint;
+
+import javax.annotation.Nullable;
+
+/**
+ * Describes one attempt to transfer user data between physically separated 
parts of IoTDB. Payload
+ * contents and exception messages must not be included in this event.
+ */
+public final class UserDataTransferAuditEvent {
+
+  private final long timestamp;
+  private final UserDataTransferType transferType;
+  private final TEndPoint initiator;
+  private final TEndPoint source;
+  private final TEndPoint target;
+  private final UserDataTransferProtectionMethod protectionMethod;
+  private final String protectionProtocol;

Review Comment:
   Addressed in 43a7104b17. The event model now contains only timestamp, 
initiator, source, target, protection method, result, and one error value. 
Transfer type, protocol, context, attempt number, and split error fields were 
removed; routing still uses AuditEventType.USER_DATA_TRANSFER.



##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/audit/AbstractAuditLogger.java:
##########
@@ -136,4 +138,53 @@ 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())) {

Review Comment:
   Addressed in 43a7104b17. Plan dispatch now excludes the built-in internal 
audit user, and the IoTConsensus classifier resolves the DataRegion database 
and excludes the audit database before emitting an event. Added focused tests 
for both audit-origin and audit-database exclusion.



##########
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/client/DispatchLogHandler.java:
##########
@@ -172,4 +185,35 @@ private void completeBatch(Batch batch) {
     // removeBatch
     thread.updateSafelyDeletedSearchIndex();
   }
+
+  private void recordTransferAttempt(boolean success, String errorCode, 
Throwable error) {
+    if (!thread.getImpl().getUserDataTransferAuditHandler().isEnabled()) {

Review Comment:
   Addressed in 43a7104b17. Handler lookup, isEnabled(), event construction, 
and onAttempt() are all inside the isolation boundary. The handler contract now 
explicitly requires prompt, non-blocking, no-throw behavior, and a 
throwing-handler test verifies replication callbacks are unaffected.



##########
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/client/DispatchLogHandler.java:
##########
@@ -63,6 +66,15 @@ public DispatchLogHandler(
 
   @Override
   public void onComplete(TSyncLogEntriesRes response) {
+    final TSStatus failedStatus =
+        response.getStatuses().stream()
+            .filter(status -> status.getCode() != 
TSStatusCode.SUCCESS_STATUS.getStatusCode())
+            .findFirst()
+            .orElse(null);
+    recordTransferAttempt(

Review Comment:
   Addressed in 43a7104b17. Added an injected user-data classifier, propagated 
the classification through IndexedConsensusRequest, Batch, and WAL 
reconstruction, and DispatchLogHandler now emits only when the batch contains 
user data. Non-user batches are covered by a focused test.



-- 
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