You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/08/18 04:14:50 UTC
[GitHub] [shardingsphere] sandynz opened a new issue, #20258: Execute 'select count(1) from sharding_db.t_order' on proxy 'sys' database throw NPE
sandynz opened a new issue, #20258:
URL: https://github.com/apache/shardingsphere/issues/20258
## Bug Report
### Which version of ShardingSphere did you use?
master branch, 0bcf67adffa0c617892cab0c318e0d79992145a5
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
proxy
### Expected behavior
No exception thrown
### Actual behavior
Error occur:
```
mysql> use sys
Database changed
mysql> select count(1) from sharding_db.t_order;
ERROR 1999 (42000): Unknown exception: null
```
Error log in proxy:
```
[ShardingSphere-Command-0] o.a.s.p.f.c.CommandExecutorTask - Exception occur:
java.lang.NullPointerException: null
at org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.JDBCBackendStatement.setFetchSize(JDBCBackendStatement.java:81)
at org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.JDBCBackendStatement.createStorageResource(JDBCBackendStatement.java:52)
at org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.JDBCBackendStatement.createStorageResource(JDBCBackendStatement.java:42)
at org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.builder.StatementExecutionUnitBuilder.createStatement(StatementExecutionUnitBuilder.java:44)
at org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.builder.StatementExecutionUnitBuilder.build(StatementExecutionUnitBuilder.java:39)
at org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.builder.StatementExecutionUnitBuilder.build(StatementExecutionUnitBuilder.java:34)
at org.apache.shardingsphere.infra.executor.sql.prepare.driver.DriverExecutionPrepareEngine.createExecutionGroup(DriverExecutionPrepareEngine.java:94)
at org.apache.shardingsphere.infra.executor.sql.prepare.driver.DriverExecutionPrepareEngine.group(DriverExecutionPrepareEngine.java:85)
at org.apache.shardingsphere.infra.executor.sql.prepare.AbstractExecutionPrepareEngine.prepare(AbstractExecutionPrepareEngine.java:62)
at org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor.useDriverToExecute(ProxySQLExecutor.java:187)
at org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor.execute(ProxySQLExecutor.java:153)
at org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor.execute(ProxySQLExecutor.java:147)
at org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.execute(JDBCDatabaseCommunicationEngine.java:132)
at org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:94)
at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:112)
at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:78)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
```
### Reason analyze (If you can)
Screenshot:
<img width="1396" alt="图片" src="https://user-images.githubusercontent.com/42492540/185292016-5a69b4b2-8568-4865-9249-5bb4802806c9.png">
JDBCBackendStatement could not get databaseType by current databaseName.
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
1, Prepare sharding_db and t_order
2, Execute SQL:
```
mysql> use mysql
mysql> select count(1) from sharding_db.t_order;
```
### Example codes for reproduce this issue (such as a github link).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Execute 'select count(1) from sharding_db.t_order' on proxy 'sys' database throw NPE [shardingsphere]
Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu commented on issue #20258:
URL: https://github.com/apache/shardingsphere/issues/20258#issuecomment-5707753553
Hi @sandynz, thanks for reporting this.
This issue has already been resolved on the current `master` branch. The root cause was similar to #16325, but it was not the same case. At the reported commit, `JDBCBackendStatement` obtained the `DatabaseType` from the currently selected database. Therefore, when the current database was `sys` or `mysql` while the SQL explicitly accessed `sharding_db.t_order`, the metadata lookup could return null and cause an NPE in `setFetchSize()`.
#20115 removed `SQLStatementDatabaseHolder` and eliminated the metadata lookup based on the current database name from `JDBCBackendStatement`. #21715 later improved this path by explicitly passing the `DatabaseType` of the actual storage unit to `JDBCBackendStatement`. The current implementation determines the logical database from the SQL context first, so the original NPE path no longer exists.
Please verify the following scenario with the current `master` branch or a newer version that includes #20115 and #21715:
`USE sys; SELECT COUNT(1) FROM sharding_db.t_order;`
If it can no longer be reproduced, I suggest labeling this issue as `type: duplicate`, retaining `in: metadata`, and closing it. If it is still reproducible, please provide the current commit ID, Proxy configuration, and complete exception stack trace so that we can check whether it has a different root cause.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] github-actions[bot] commented on issue #20258: Execute 'select count(1) from sharding_db.t_order' on proxy 'sys' database throw NPE
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #20258:
URL: https://github.com/apache/shardingsphere/issues/20258#issuecomment-1272348832
Hello , this issue has not received a reply for several days.
This issue is supposed to be closed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Execute 'select count(1) from sharding_db.t_order' on proxy 'sys' database throw NPE [shardingsphere]
Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu closed issue #20258: Execute 'select count(1) from sharding_db.t_order' on proxy 'sys' database throw NPE
URL: https://github.com/apache/shardingsphere/issues/20258
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] github-actions[bot] closed issue #20258: Execute 'select count(1) from sharding_db.t_order' on proxy 'sys' database throw NPE
Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed issue #20258: Execute 'select count(1) from sharding_db.t_order' on proxy 'sys' database throw NPE
URL: https://github.com/apache/shardingsphere/issues/20258
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] RaigorJiang commented on issue #20258: Execute 'select count(1) from sharding_db.t_order' on proxy 'sys' database throw NPE
Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang commented on issue #20258:
URL: https://github.com/apache/shardingsphere/issues/20258#issuecomment-1407558313
Similar to #16325, but not the same issue.
Hi @tuichenchuxin can you take a look?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] tuichenchuxin commented on issue #20258: Execute 'select count(1) from sharding_db.t_order' on proxy 'sys' database throw NPE
Posted by "tuichenchuxin (via GitHub)" <gi...@apache.org>.
tuichenchuxin commented on issue #20258:
URL: https://github.com/apache/shardingsphere/issues/20258#issuecomment-1409718513
sure.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org