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


##########
fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java:
##########
@@ -369,6 +371,46 @@ public void clearLastDBOfCatalog() {
         lastDBOfCatalog.clear();
     }
 
+    public void resetConnection() throws UserException {
+        closeTxnForConnectionReset();
+        if (!dbToTempTableNamesMap.isEmpty()) {
+            cleanupTemporaryTables(true);
+            dbToTempTableNamesMap.clear();
+        }
+        resetSessionVariable();
+        userVars = new HashMap<>();
+        preparedQuerys.clear();
+        preparedStatementContextMap.clear();
+        preparedStmtId = INITIAL_PREPARED_STMT_ID;
+        runningQuery = null;
+        resetQueryId();
+        insertResult = null;

Review Comment:
   `resetSessionVariable()` clears `@@session_context`, but the side effect 
from setting that variable is stored separately in `ConnectContext.traceId`. 
With this reset path, a client can run `set session_context='trace_id:old'`, 
send `COM_RESET_CONNECTION`, and the fresh `SessionVariable` no longer contains 
that context while `traceId` still appears in `SHOW PROCESSLIST` and future 
`setQueryId()` calls continue to associate new queries with the old trace 
through `connectScheduler`. Please clear the derived trace id as part of reset, 
using `setTraceId(null)` so the old scheduler mapping is removed too.
   
   ```suggestion
           runningQuery = null;
           resetQueryId();
           setTraceId(null);
           insertResult = null;
   ```



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