fix: allow public key retrieval for MySQL family datasources - #48
Open
LordofAvernus wants to merge 1 commit into
Open
LordofAvernus wants to merge 1 commit into
LordofAvernus wants to merge 1 commit into
Conversation
MySQL 8 defaults to caching_sha2_password. When the server side authentication cache misses, the driver has to fetch the server RSA public key to encrypt the password, but ODC builds the JDBC url with useSSL=false and without allowPublicKeyRetrieval, so Connector/J refuses the retrieval and the connection fails with "Public Key Retrieval is not allowed". Default allowPublicKeyRetrieval to true in the MySQL connect plugin so test connection, SQL console, data transfer and DLM all get it. Values supplied by the datasource still win, and TiDB / Doris inherit it. Also build the parameter map from a copy instead of mutating the caller's map: DataSourceInfoMapper passes Collections.emptyMap(), which made the previous in-place put throw UnsupportedOperationException, and a null map silently dropped the defaults.
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.
关联的 issue
https://github.com/actiontech/dms-ee/issues/989
描述你的变更
MySQLConnectionExtension.appendDefaultJdbcUrlParameters默认补allowPublicKeyRetrieval=true,修掉 MySQL 8caching_sha2_password账号在认证缓存未命中时报Public Key Retrieval is not allowed的问题(ODC 拼串固定useSSL=false,驱动在非 SSL 下默认禁止取服务端公钥)putIfAbsent保证数据源自带的jdbcUrlParameters优先,需要走 SSL 的场景可显式配false覆盖DataSourceInfoMapper传Collections.emptyMap(),原实现在 DLM 路径会抛UnsupportedOperationException;入参为null时原实现还会静默丢掉默认参数OBMySQLConnectionExtension与OBConsoleDataSourceFactory;生效类型为MYSQL、DORIS、TIDB(后两者继承且未覆写该方法),不影响 OceanBase / Oracle / PostgreSQL 等MySQLConnectionExtensionTest(纯单测,不依赖真库)6 个用例:默认值生效、用户显式false不被覆盖、null入参、不可变 map 不抛异常、调用方 map 不被污染、不串入 OceanBase 专有的enableFullLinkTrace自测记录:
./mvnw -Dci -pl server/plugins/connect-plugin-mysql -am -Dmaven.test.skip=false -Dtest=MySQLConnectionExtensionTest test(JDK 8)6 项全绿,formatter / license / impsort 校验通过。回滚实现后同组用例 4 项失败,其中不可变 map 用例确实抛出UnsupportedOperationException。确认项(pr提交后操作)
Tip
请在指定复审人之前,确认并完成以下事项,完成后✅
not_compatibleneed_update_doc