github-actions[bot] commented on code in PR #64569:
URL: https://github.com/apache/doris/pull/64569#discussion_r3420659911
##########
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:
`isSingleSetVar` is broader than "the statement used a SET_VAR hint". It is
also flipped by internal planner calls to `SessionVariable.setVarOnce()`, for
example `NereidsPlanner.optimize()` -> `configRuntimeFilterWaitTime()` adjusts
`runtime_filter_wait_time_ms` for external scans, and
`StatsCalculator.disableJoinReorderIfStatsInvalid()` can set
`disable_join_reorder` for ordinary SELECTs with invalid stats. With this
snapshot taken before `revertSessionValue`, those statements will now write
these internal temporary variables into audit `changed_variables` even though
the user did not set a hint or session variable. That changes audit semantics
for non-SET_VAR queries. Please gate this on an explicit SET_VAR-hint marker,
or record the hint-set variables separately, instead of using the generic
`isSingleSetVar` flag.
##########
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:
This global setting is restored only on the success path at the end of the
suite. If table creation, insert, audit polling, or the assertion throws,
`enable_audit_plugin` remains enabled and can pollute later `nonConcurrent`
suites. Neighboring audit tests use
`setGlobalVarTemporary([enable_audit_plugin: true], { ... })`, which restores
in `finally` and also handles the ADMIN skip path. Please wrap the test body in
that helper instead of manually setting and resetting the global variable.
--
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]