apache / apache/shardingsphere
DistSQL pymysql execute error
- Dominant language
- Java
- Stars
- 20.8k
- Forks
- 6.9k
- Avg merge
- 11h 35m
- Merged PRs (30d)
- 326
Description
## Bug Report
**For English only**, other languages will not accept.
Before report a bug, make sure you have:
- Searched open and closed [GitHub issues](https://github.com/apache/shardingsphere/issues).
- Read documentation: [ShardingSphere Doc](https://shardingsphere.apache.org/document/current/en/overview).
Please pay attention on issues you submitted, because we maybe need more details.
If no response anymore and we cannot reproduce it on current information, we will **close it**.
Please answer these questions before submitting your issue. Thanks!
### Which version of ShardingSphere did you use?
5.5.0
pymysql 0.10.1
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
shardingsphere-proxy
1. pymysql connect shardingsphere-proxy ----- success
2. pymysql create database and use database. pymysql.connect.commit() ----- success
3. pymysql register two storage unit ----- success
4. show storage units ----- success
5. unregister first storage unit ------ failed
pass first exception. and continue unregister second storage unit --- success
### Expected behavior
unregister success
### Actual behavior
unregister failed .
### Reason analyze (If you can)
[ERROR] 2024-05-17 14:45:33.802 [ShardingSphere-Command-16] o.a.s.p.f.c.CommandExecutorTask - Exception occur:
java.lang.NullPointerException: null
at org.apache.shardingsphere.infra.datasource.pool.CatalogSwitchableDataSource.getConnection(CatalogSwitchableDataSource.java:46)
at org.apache.shardingsphere.infra.database.DatabaseTypeEngine.getStorageType(DatabaseTypeEngine.java:118)
at org.apache.shardingsphere.infra.database.DatabaseTypeEngine.getProtocolType(DatabaseTypeEngine.java:62)
at org.apache.shardingsphere.metadata.factory.ExternalMetaDataFactory.create(ExternalMetaDataFactory.java:54)
at org.apache.shardingsphere.mode.manager.context.ConfigurationContextManager.createChangedDatabase(ConfigurationContextManager.java:334)
at org.apache.shardingsphere.mode.manager.context.ConfigurationContextManager.createChangedDatabases(ConfigurationContextManager.java:306)
at org.apache.shardingsphere.mode.manager.context.ConfigurationContextManager.createMetaDataContexts(ConfigurationContextManager.java:282)
at org.apache.shardingsphere.mode.manager.standalone.StandaloneModeContextManager.unregisterStorageUnits(StandaloneModeContextManager.java:246)
at org.apache.shardingsphere.distsql.handler.executor.rdl.resource.UnregisterStorageUnitExecutor.executeUpdate(UnregisterStorageUnitExecutor.java:60)
at org.apache.shardingsphere.distsql.handler.executor.rdl.resource.UnregisterStorageUnitExecutor.executeUpdate(UnregisterStorageUnitExecutor.java:47)
at org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecuteEngine.executeNormalUpdate(DistSQLUpdateExecuteEngine.java:86)
at org.apache.shardingsphere.distsql.handler.engine.update.DistSQLUpdateExecuteEngine.executeUpdate(DistSQLUpdateExecuteEngine.java:64)
at org.apache.shardingsphere.proxy.backend.handler.distsql.DistSQLUpdateBackendHandler.execute(DistSQLUpdateBackendHandler.java:45)
at org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:86)
at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.doExecuteCommand(CommandExecutorTask.java:126)
at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:121)
at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:78)
at com.alibaba.ttl.TtlRunnable.run(TtlRunnable.java:60)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
### Example codes for reproduce this issue (such as a github link).
Contributor guide
Research direction
Start with the reported stack trace at CatalogSwitchableDataSource.getConnection and follow the unregister path through StandaloneModeContextManager.unregisterStorageUnits, ExternalMetaDataFactory.create, and DatabaseTypeEngine. Reproduce the two-storage-unit PyMySQL workflow against ShardingSphere-Proxy 5.5.0; done means the first storage-unit unregister completes without the reported NullPointerException and the second remains usable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, mysql, python
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 22/100