single table throw NoSuchTableException in method validateTableExist
Bug Report
For English only, other languages will not accept.
Before report a bug, make sure you have:
- Searched open and closed GitHub issues.
- Read documentation: ShardingSphere Doc.
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.4.0
Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-JDBC
Expected behavior
Actual behavior
throw NoSuchTableException
Reason analyze (If you can)
Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
my project upgrade from 4.0.0-RC2-SNAPSHOT to 5.4.0
tables in mysql database: db_uc
tb_third_employee_000 tb_third_employee_001 tb_uc_account
tableName=tb_third_employee, column=organization_id
Properties properties = new Properties();
properties.setProperty("algorithm-expression", tableName + "_00${" + column + " % 2}");
String shardingStrategyKey = "sharding_algorithm_" + tableName;
shardingRuleConfig.getShardingAlgorithms().put(shardingStrategyKey, new AlgorithmConfiguration("INLINE", properties));
shardingRuleConfig.getBindingTableGroups().add(new ShardingTableReferenceRuleConfiguration("db_" + schemaName, tableName));
ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration(tableName, "db_" + schemaName + "." + tableName + "_00${[0, 1]}");
result.setTableShardingStrategy(new StandardShardingStrategyConfiguration(column, shardingStrategyKey));
shardingRuleConfig.getTables().add(result);
// create datasource
Properties pop = new Properties();
pop.setProperty(ConfigurationPropertyKey.SQL_SHOW.getKey(), Boolean.TRUE.toString());
pop.setProperty(ConfigurationPropertyKey.SQL_SIMPLE.getKey(), Boolean.FALSE.toString());
dataSource = ShardingSphereDataSourceFactory.createDataSource("db_" + schema, ds, Lists.newArrayList(shardingRuleConfig), pop);
Example codes for reproduce this issue (such as a github link).
is no sharding table must in a default database ?
i also encountered this problem, if it is not a sharding table , it will appear 'table not exist'
Please refer this document to config single table rule - https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-jdbc/yaml-config/rules/single/.
Starting from 5.4.0, the single table will not be loaded by default, users need to declare in yaml or use LOAD SINGLE TABLE to load.
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.