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


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

Review Comment:
   `cleanupTemporaryTables(true)` iterates `dbToTempTableNamesMap` and each 
table-name set, but dropping a temporary table mutates that same set through 
`dropTableWithoutCheck()` -> `Database.unregisterTable()` -> 
`Env.unregisterTempTable()` -> `ConnectContext.removeTempTableFromDB()`. With 
two temporary tables in the session, the first drop removes the current element 
and the enhanced-for iterator throws `ConcurrentModificationException` on the 
next element. That exception is not a `UserException`, so 
`COM_RESET_CONNECTION` can fail the connection and leave the remaining 
temporary tables/session state uncleared. Please iterate over snapshots of the 
db/table names before dropping (and keep clearing the map after the snapshot 
cleanup completes).



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