Gabriel39 commented on code in PR #67053:
URL: https://github.com/apache/doris/pull/67053#discussion_r3859640839


##########
fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java:
##########
@@ -408,12 +409,41 @@ private static void logAuditLogImpl(ConnectContext ctx, 
String origStmt, Stateme
             auditEventBuilder.setState(String.valueOf(MysqlStateType.OK));
         }
         AuditEvent event = auditEventBuilder.build();
-        
Env.getCurrentEnv().getWorkloadRuntimeStatusMgr().submitFinishQueryToAudit(event);
+        Set<Long> externalInsertBackendIds = 
getSuccessfulExternalInsertBackendIds(ctx, parsedStmt);
+        if (externalInsertBackendIds.isEmpty()) {
+            
Env.getCurrentEnv().getWorkloadRuntimeStatusMgr().submitFinishQueryToAudit(event);
+        } else {
+            Env.getCurrentEnv().getWorkloadRuntimeStatusMgr()
+                    .submitFinishQueryToAudit(event, externalInsertBackendIds);
+        }
         if (LOG.isDebugEnabled()) {
             LOG.debug("submit audit event: {}", event.queryId);
         }
     }
 
+    private static Set<Long> getSuccessfulExternalInsertBackendIds(
+            ConnectContext ctx, StatementBase parsedStmt) {
+        MysqlStateType stateType = ctx.getState().getStateType();
+        if (stateType != MysqlStateType.OK && stateType != MysqlStateType.EOF) 
{
+            return ImmutableSet.of();
+        }
+        if (!(parsedStmt instanceof LogicalPlanAdapter)) {
+            return ImmutableSet.of();
+        }
+        LogicalPlan logicalPlan = ((LogicalPlanAdapter) 
parsedStmt).getLogicalPlan();
+        if (!(logicalPlan instanceof InsertIntoTableCommand)

Review Comment:
   Fixed in 46c097c474. Audit routing no longer inspects the logical root. 
InsertIntoTableCommand registers the barrier only from the resolved 
BaseExternalTableInsertExecutor or RemoteOlapInsertExecutor, while FILES 
registers its unambiguous external sink directly. The tests cover plugin-driven 
and Remote Doris executors as positive cases and internal OLAP and blackhole 
executors as negative cases.



##########
fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java:
##########
@@ -3842,6 +3843,10 @@ public List<TNetworkAddress> getInvolvedBackends() {
         return backendAddresses;
     }
 
+    public Set<Long> getInvolvedBackendIds() {
+        return ImmutableSet.copyOf(beToPipelineExecCtxs.keySet());

Review Comment:
   Fixed in 46c097c474. Classic and Nereids coordinators now keep a separate 
audit participant set populated immediately before each fragment RPC attempt. 
Serialization or setup failure before dispatch leaves it empty; partial 
dispatch includes completed and uncertain attempts but excludes later workers 
that were never attempted. PipelineExecutionTaskTest covers the 
partial-dispatch boundary.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to