fix(mysql): preserve temporary tables in client session pools#1531
Merged
Conversation
Disable COM_RESET_CONNECTION for single-connection session pools (max_connections == 1) so that MySQL session state such as TEMPORARY TABLEs is not cleared when a connection is returned to the pool. Closes t8y2#1509
Owner
|
Thanks for the fix! 🎉 |
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.
Disable COM_RESET_CONNECTION for single-connection session pools (max_connections == 1) so that MySQL session state such as TEMPORARY TABLEs is not cleared when a connection is returned to the pool.
Closes #1509
变更说明
在同一个 client session 中分步执行 SQL 时,创建的临时表在后续查询中报不存在。
根因:
mysql_async连接池默认在连接归还时发送COM_RESET_CONNECTION,该命令会清除所有临时表及 session 状态。即使 session 池已限制max_connections = 1(确保复用同一物理连接),reset 仍会销毁临时表。修复:在
create_pool中,当max_connections == 1(即 client session 池)时,设置.with_reset_connection(false)跳过COM_RESET_CONNECTION,保留临时表等 session 状态。非 session 池(max_connections > 1)行为不变。变更类型
涉及前端
验证
cargo check --no-default-features通过cargo test -p dbx-core:1037 passed, 0 failed)关联 Issue
Close #1509