Repository navigation
Description
Description
MatrixOne declares MySQL protocol commands COM_RESET_CONNECTION (0x1f) and COM_CHANGE_USER (0x11) but does not execute either command. As a result, Connector/J's standard MysqlConnectionPoolDataSource creates the physical connection but cannot return even the first logical pooled connection.
Environment
- Branch:
main - Commit:
1891117aedce0419a81630b3011906b560b93d0a - Deployment: local single-node launch (
etc/launch/launch.toml) - OS: macOS arm64
- Drivers: MySQL Connector/J 8.0.15, 8.4.0, and 9.7.0
Steps to reproduce
MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
ds.setURL("jdbc:mysql://127.0.0.1:6001/test");
ds.setUser(user);
ds.setPassword(password);
PooledConnection pooled = ds.getPooledConnection(); // physical connection succeeds
Connection logical = pooled.getConnection(); // fails during server-state resetConnector/J calls JdbcConnection.resetServerState() before exposing a logical connection. Modern versions send COM_RESET_CONNECTION; Connector/J 8.0.15 resets through COM_CHANGE_USER.
Actual behavior
Connector/J 8.4.0 and 9.7.0:
java.sql.SQLException: internal error: unsupported command. 0x1f
at com.mysql.cj.jdbc.ConnectionImpl.resetServerState(...)
at com.mysql.cj.jdbc.MysqlPooledConnection.getConnection(...)
Connector/J 8.0.15:
java.sql.SQLException: internal error: unsupported command. 0x11
at com.mysql.cj.jdbc.ConnectionImpl.changeUser(...)
at com.mysql.cj.jdbc.ConnectionImpl.resetServerState(...)
at com.mysql.cj.jdbc.MysqlPooledConnection.getConnection(...)
No logical connection can be borrowed from this standard JDBC pool interface.
Expected behavior
MysqlConnectionPoolDataSource.getPooledConnection().getConnection() should succeed. Resetting a pooled session should preserve the authenticated physical connection while restoring clean session state, including rolling back an active transaction, clearing user variables, dropping temporary tables, releasing prepared statements/cursors, and restoring session defaults according to MySQL protocol semantics.
Stability and controls
- Reproducer: 3/3 with Connector/J 8.4.0 (
0x1f). - Cross-version: reproduced with Connector/J 8.0.15 (
0x11) and 9.7.0 (0x1f). - Direct JDBC control: ordinary DriverManager connections and
connection_id()queries pass. - HikariCP 5.1 control: 10 assertions pass, covering physical connection reuse, rollback on logical close, autocommit restoration,
isValid(), and replacement afterConnection.abort(). - No panic, hang, data corruption, or CN restart was observed.
Code analysis
pkg/frontend/mysql_protocol_predefines.go declares both commands. However, ExecRequest in pkg/frontend/mysql_cmd_executor.go has no COM_RESET_CONNECTION or COM_CHANGE_USER branch, so both fall into the default unsupported command response.
Regression coverage
After the fix, add a JDBC/motr test using MysqlConnectionPoolDataSource that verifies first and repeated logical borrows, stable physical connection ID, active-transaction rollback, user-variable cleanup, temporary-table cleanup, prepared-statement cleanup, and clean reuse after a reset error. This is protocol/session coverage and does not require big-data testing.
Activity
iamlinjunhong commentedon Aug 26, 2026
Additional MatrixOne ODBC / unixODBC evidence confirms the same protocol gap affects ODBC connection-pool hygiene, not only Connector/J.
Environment:
1891117aedce0419a81630b3011906b560b93d0a390f3cc58ebc06d5e830a7839cccbca2962ffcc4ODBC reproduction:
With pyodbc/unixODBC pooling enabled, the third logical connection reuses a physical connection and can still read the prior borrower's temporary table. With
pyodbc.pooling = False, the same 12-scenario run cleans the temporary table correctly and improves from 8/12 to 10/12; the remaining two failures are unrelated known compatibility differences.Native libmysqlclient controls against this MatrixOne commit confirm both reset paths required by the upstream MySQL ODBC pooling implementation are rejected:
The upstream MySQL ODBC reset path marks a pooled connection for wake-up and calls
mysql_change_user()before reuse. Therefore MatrixOne currently cannot provide the server-side session reset needed to drop temporary tables, clear variables and restore defaults on pooled reuse.Evidence:
artifacts/production-release-20260826/server-rounds-latest/results/server-scenarios-round3.json(R302)artifacts/production-release-20260826/server-rounds-no-pool/results/server-scenarios-round3.json(R302control)artifacts/production-release-20260826/logs/mysql-change-user-temp-repro-1891117.logartifacts/production-release-20260826/logs/mysql-reset-connection-temp-repro-1891117.logTemporary workaround: disable pyodbc/unixODBC pooling for workloads that use session-scoped state (temporary tables, user variables, session options), and explicitly roll back before close.
iamlinjunhong commentedon Aug 26, 2026
ODBC/unixODBC confirmation on the latest tested MatrixOne main:
a53f5a3b757c5b21a36e539e4471533fe1d091a8390f3cc58ebc06d5e830a7839cccbca2962ffcc4Native libmysqlclient controls still fail:
With Driver Manager pooling enabled, a temporary table created during one logical pyodbc connection remains present when the same physical connection is borrowed again, so the second
CREATE TEMPORARY TABLEunexpectedly succeeds as a lookup but fails the isolation assertion. The same scenario passes when pooling is disabled. A later concurrent DDL case can also observe a stale session/causal state and report42S02for a table just created by another logical connection.Temporary workaround remains: disable Driver Manager pooling for workloads that depend on clean session state, and explicitly roll back before returning a connection.
fix(frontend): support MySQL session reset commands (#27736)
Ariznawlll commentedon Sep 8, 2026
测试版本
原问题验证
同一物理连接创建临时表、设置用户变量并开启未提交事务后发送 COM_RESET_CONNECTION。3 轮均保持 connection id 和当前 database,变量清空、临时表不可见、未提交写入回滚。
Happy Path 覆盖
Unhappy Path 覆盖
白盒验证
pkg/frontend 的 TestMySQLWireChangeUserAuthSwitchAndRepeatedBorrow 与 TestMySQLWireResetConnectionPreservesDatabase 3 轮通过。
回归测试
已加入 motr#151:14_issue_regression.issue_27644_pooled_session_reset,涵盖真实 reset 与两次 change-user,MOTR 3 轮通过。
测试证据
每轮均验证同一物理连接、变量/临时表/事务清理,以及两次认证切换。
测试结论
测试通过。
fix(frontend): support MySQL session reset commands (matrixorigin#27736)
fix(frontend): support MySQL session reset commands (matrixorigin#27736)
fix(frontend): support MySQL session reset commands (matrixorigin#27736)