github-actions[bot] commented on code in PR #63865:
URL: https://github.com/apache/doris/pull/63865#discussion_r3332258586


##########
regression-test/suites/audit/test_audit_log_label_txn_id.groovy:
##########
@@ -0,0 +1,134 @@
+// 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.
+
+suite("test_audit_log_label_txn_id","nonConcurrent") {
+    try {

Review Comment:
   This test enables the global audit plugin but only disables it at the very 
end. Any failure between this line and the final `set global 
enable_audit_plugin = false` leaves the global setting enabled for later suites 
in the same regression run, which can make unrelated tests non-deterministic 
and keep writing audit rows. Please restore the original/global value in a 
`finally` block (or otherwise guarantee cleanup) around the body after the 
privilege check succeeds.



##########
fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java:
##########
@@ -69,12 +69,18 @@ public class AuditLogHelper {
 
     private static final Logger LOG = 
LogManager.getLogger(AuditLogHelper.class);
     private static final Set<String> LOG_PLAN_INFO_TYPES = 
Sets.newTreeSet(String.CASE_INSENSITIVE_ORDER);
+    private static final Set<String> TXN_STMT_TYPES = 
Sets.newTreeSet(String.CASE_INSENSITIVE_ORDER);
 
     static {

Review Comment:
   `ConnectContext.getInsertResult()` is the session's last insert result used 
by `SHOW LAST INSERT`, and it is not cleared at statement start. That means an 
audited transactional statement can inherit stale metadata from a previous 
successful insert/update/delete in the same connection. For example: run a 
successful `insert` so `insertResult` is populated, then run an `insert` that 
fails during analysis/execution before `setOrUpdateInsertResult()` is called, 
or a `delete` that reaches `processEmptyRelation()` and reports txnId `-1` 
without updating the context. `stmtType` is still `INSERT`/`DELETE`, so this 
block writes the previous statement's label/txn_id into the current audit row. 
The audit fields need to be scoped to the current statement/result, or 
`insertResult` must be cleared/validated for the current statement before it is 
used here.



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