apache / shardingsphere

Empowering Data Intelligence with Distributed SQL for Sharding, Scalability, and Security Across All Databases.
Apache License 2.0
19.92k stars 6.73k forks source link

Execute 'select count(1) from sharding_db.t_order' on proxy 'sys' database throw NPE #20258

Open sandynz opened 2 years ago

sandynz commented 2 years ago

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:

图片

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).

github-actions[bot] commented 2 years ago

Hello , this issue has not received a reply for several days. This issue is supposed to be closed.

RaigorJiang commented 1 year ago

Similar to #16325, but not the same issue. Hi @tuichenchuxin can you take a look?

tuichenchuxin commented 1 year ago

sure.