924060929 commented on code in PR #64569:
URL: https://github.com/apache/doris/pull/64569#discussion_r3425719939


##########
fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java:
##########
@@ -650,6 +658,17 @@ public void execute(TUniqueId queryId) throws Exception {
                 throw e;
             }
         } finally {
+            // Snapshot changed session variables (including SET_VAR hint 
values) BEFORE revert,
+            // so the audit log (logged after execute() returns, i.e. after 
the revert below) can

Review Comment:
   This broader capture is intentional. The audit log's `changed_variables` is 
meant to reflect the session variables that were actually in effect for the 
statement. When the planner implicitly adjusts a variable such as 
`runtime_filter_wait_time_ms` via `setVarOnce()`, that value did take effect 
for the query, so surfacing it in the audit gives visibility into implicit 
changes that would otherwise be invisible. Recording per-query temporary 
changes — whether from a user `SET_VAR` hint or an internal `setVarOnce()` — is 
by design here, not only the hint case.
   



##########
regression-test/suites/audit/test_audit_log_hint_session_context.groovy:
##########
@@ -0,0 +1,71 @@
+// 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.
+
+// A session variable changed by a per-query SET_VAR hint is temporary: it is 
reverted in
+// StmtExecutor.execute()'s finally block. The audit log is built afterwards 
(in auditAfterExec),
+// so without a pre-revert snapshot the hint value never reaches 
changed_variables. This case
+// verifies that a per-query SET_VAR(session_context=...) is recorded in the 
audit log's
+// changed_variables. The value is quoted so the hint parser keeps the ':' in 
the value.
+suite("test_audit_log_hint_session_context", "nonConcurrent") {
+    try {
+        sql "set global enable_audit_plugin = true"

Review Comment:
   Fair point. In practice the impact is low — leaving `enable_audit_plugin` 
enabled on an early failure only causes later suites to write a few extra audit 
rows, which don't affect their assertions — but 
`setGlobalVarTemporary([enable_audit_plugin: true]) { ... }` is cleaner and 
consistent with the neighboring audit cases. Happy to switch to it.
   



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