branch-4.0: [fix](connect) Align COM_RESET_CONNECTION behavior with MySQL #63884#64074
Open
yujun777 wants to merge 9 commits into
Open
branch-4.0: [fix](connect) Align COM_RESET_CONNECTION behavior with MySQL #63884#64074yujun777 wants to merge 9 commits into
yujun777 wants to merge 9 commits into
Conversation
COM_RESET_CONNECTION should clear session-scoped state without losing user-level default session settings such as query and insert timeout. Key changes: - Reset session variables, user variables, prepared statements, catalog/database state, running query, and return rows on COM_RESET_CONNECTION. - Reapply user default query_timeout and insert_timeout after rebuilding SessionVariable. - Add a regression helper to send COM_RESET_CONNECTION directly through the MySQL protocol. Unit Test: - ConnectContextTest - test_reset_connection_session_variable
COM_RESET_CONNECTION should reset per-connection state without clearing the current database, and cleanup failures should be returned to clients instead of silently succeeding. Key changes: - Preserve current catalog and database across reset connection. - Reset user variables, prepared statements, running query state, insert result, temporary tables, and transaction state. - Return autocommit server status on reset OK and MySQL-compatible prepared statement errors. Unit Test: - ConnectContextTest - test_reset_connection_session_variable - FE checkstyle validate
Align reset connection handling with Doris' existing MySQL OK packet behavior and make prepared statement reset report cleared statement ids immediately. Key changes: - Do not set autocommit server status in COM_RESET_CONNECTION OK packets - Clear query id during connection reset - Parse COM_STMT_RESET statement id and return unknown statement errors for cleared statements Unit Test: - ConnectContextTest
### What problem does this PR solve? Issue Number: close apache#63884 Related PR: apache#63884 Problem Summary: Extend the COM_RESET_CONNECTION regression coverage to verify that reset keeps the current database while restoring session state, clears user variables, and invalidates server-side prepared statements from the previous session state. ### Release note None ### Check List (For Author) - Test: Regression test - Attempted ./run-regression-test.sh --run -d query_p0/session_variable -s test_reset_connection_session_variable, but the local FE mysql port 127.0.0.1:59130 timed out before the case could complete. - Behavior changed: No - Does this need documentation: No
Extend the reset connection regression to cover user variables, processlist state, and server-side prepared statements after COM_RESET_CONNECTION. Key changes: - Send COM_RESET_CONNECTION directly in the regression case. - Verify reset clears user variables, processlist QueryId/Info, and server prepared statement handlers. Unit Test: - ./run-regression-test.sh --run -d query_p0/session_variable -s test_reset_connection_session_variable
Use a named constant for the initial prepared statement id and keep temporary table map cleanup scoped to connections that have temporary tables. Key changes: - Add INITIAL_PREPARED_STMT_ID for prepared statement id initialization and reset - Move temporary table map clear into the non-empty cleanup branch Unit Test: - ConnectContextTest
COM_RESET_CONNECTION can drop temporary tables through a path that unregisters them from the current ConnectContext while cleanup is iterating the session temporary-table map. Key changes: - Iterate over a snapshot of temporary table names during reset cleanup. - Apply the same snapshot iteration to local master cleanup and forwarded cleanup. - Add FE coverage for resetting a connection with multiple temporary tables. Unit Test: - ConnectContextTest - FE Core validate
COM_RESET_CONNECTION should clear query identity state without reusing server-side prepared statement ids from stale client handles. Key changes: - Keep the server prepared statement id counter monotonic across connection reset. - Clear current and last query ids during connection reset. - Clear derived trace id state during connection reset. Unit Test: - ConnectContextTest covers prepared statement id preservation, query id cleanup, last query id cleanup, and trace id cleanup on reset.
Backporting PR apache#63884 to branch-4.1 leaves ConnectContextTest incompatible with the branch's existing test setup. The new reset-connection cases need local Mockito mocks for catalog-related dependencies, and the env stubs must be set before ConnectContext.setEnv() initializes the default catalog. Key changes: - add missing Mockito and catalog imports used by the new reset-connection tests - use local Mockito mocks in reset-connection test cases instead of class-level JMockit mocks - stub internal catalog access before calling ConnectContext.setEnv() in the new tests Unit Test: - run-fe-ut.sh --run ConnectContextTest
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
Author
|
run buildall |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cherry-pick: #63884