yujun777 commented on code in PR #63884:
URL: https://github.com/apache/doris/pull/63884#discussion_r3340377809


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

Review Comment:
   Fixed in f5a8c578286. COM_RESET_CONNECTION now clears the prepared statement 
map but keeps the prepared statement id counter monotonic, so stale client-side 
handles cannot collide with new server-side statements after reset. Added 
ConnectContextTest coverage for preserving the next prepared statement id 
across reset.
   
   Validation:
   - tools/fast-compile-fe.sh ConnectContext.java
   - tools/fast-compile-fe.sh --test ConnectContextTest.java
   - MAVEN_OPTS="-Djdk.attach.allowAttachSelf=true" ./run-fe-ut.sh --run 
ConnectContextTest



##########
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();

Review Comment:
   Fixed in f5a8c578286. COM_RESET_CONNECTION now clears both queryId and 
lastQueryId directly instead of calling resetQueryId(), so last_query_id() no 
longer exposes the query executed before reset. Added ConnectContextTest 
coverage for lastQueryId cleanup on reset.
   
   Validation:
   - tools/fast-compile-fe.sh ConnectContext.java
   - tools/fast-compile-fe.sh --test ConnectContextTest.java
   - MAVEN_OPTS="-Djdk.attach.allowAttachSelf=true" ./run-fe-ut.sh --run 
ConnectContextTest



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