Skip to content

NoSuchElementException when execute DALStatement without USE DB #34224

Open
@RaigorJiang

Description

Bug Report

Which version of ShardingSphere did you use?

5.5.2-SNAPSHOT a6a09ba

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

ShardingSphere-Proxy

Expected behavior

Query from unicast database

Actual behavior

image

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

  1. Create logical database and register storage unit;
  2. Quit current session;
  3. Connect to Proxy and do not execute USE DB;
  4. Execute SQL
show variables where Variable_name in ('explicit_defaults_for_timestamp', 'sql_mode');
  1. Proxy log
java.util.NoSuchElementException: null
	at java.base/java.util.Collections$EmptyIterator.next(Collections.java:4310)
	at org.apache.shardingsphere.infra.session.query.QueryContext.getUsedDatabase(QueryContext.java:95)
	at org.apache.shardingsphere.proxy.backend.connector.StandardDatabaseConnector.<init>(StandardDatabaseConnector.java:126)
	at org.apache.shardingsphere.proxy.backend.connector.DatabaseConnectorFactory.newInstance(DatabaseConnectorFactory.java:52)
	at org.apache.shardingsphere.proxy.backend.handler.data.impl.UnicastDatabaseBackendHandler.execute(UnicastDatabaseBackendHandler.java:62)
	at org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:93)
	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:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions