morrySnow commented on code in PR #63884:
URL: https://github.com/apache/doris/pull/63884#discussion_r3333733452
##########
fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java:
##########
@@ -155,9 +154,15 @@ protected void handleDebug() {
}
protected void handleResetConnection() {
- ctx.changeDefaultCatalog(InternalCatalog.INTERNAL_CATALOG_NAME);
- ctx.clearLastDBOfCatalog();
- ctx.getState().setOk();
+ try {
+ ctx.resetConnection();
Review Comment:
`resetConnection()` clears `preparedStatementContextMap`, but
`COM_STMT_RESET` still never reads the statement id and `handleStmtReset()`
always returns OK. After a client sends COM_RESET_CONNECTION,
`mysql_stmt_reset()` on one of the old handles should receive an ERR packet
because the statement id is no longer valid; with this path it succeeds and the
client only sees the failure later on execute. Please parse the stmt id in
COM_STMT_RESET and return `ERR_UNKNOWN_STMT_HANDLER` when
`ctx.getPreparedStementContext(...)` is null, with the message target
`mysqld_stmt_reset`.
##########
fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java:
##########
@@ -155,9 +154,15 @@ protected void handleDebug() {
}
protected void handleResetConnection() {
- ctx.changeDefaultCatalog(InternalCatalog.INTERNAL_CATALOG_NAME);
- ctx.clearLastDBOfCatalog();
- ctx.getState().setOk();
+ try {
+ ctx.resetConnection();
+ if (ctx.getSessionVariable().autoCommit) {
+ ctx.getState().serverStatus |=
MysqlServerStatusFlag.SERVER_STATUS_AUTOCOMMIT;
+ }
Review Comment:
这个可能可以不改,因为第一次连接的时候,也没这个 auto commit
##########
fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java:
##########
@@ -369,6 +370,45 @@ 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 = Integer.MIN_VALUE;
+ runningQuery = null;
Review Comment:
This clears the textual `runningQuery`, but leaves `queryId` from the
previous statement. An idle connection that has just been reset can still show
the old query id in SHOW PROCESSLIST / connection profile APIs, which is not a
fresh-session state. Please clear the current query id as part of reset before
returning OK.
--
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]