sharding anomalies no table route info

1. The exception description

### Cause: java.lang.IllegalStateException: no table route info
        at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:122)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:113)
        at sun.reflect.GeneratedMethodAccessor234.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
        ... 47 more
Caused by: java.lang.IllegalStateException: no table route info
        at com.google.common.base.Preconditions.checkState(Preconditions.java:173)
        at io.shardingjdbc.core.routing.type.simple.SimpleRoutingEngine.routeTables(SimpleRoutingEngine.java:128)
        at io.shardingjdbc.core.routing.type.simple.SimpleRoutingEngine.route(SimpleRoutingEngine.java:66)
        at io.shardingjdbc.core.routing.router.ParsingSQLRouter.route(ParsingSQLRouter.java:124)
        at io.shardingjdbc.core.routing.router.ParsingSQLRouter.route(ParsingSQLRouter.java:87)
        at io.shardingjdbc.core.routing.PreparedStatementRoutingEngine.route(PreparedStatementRoutingEngine.java:57)
        at io.shardingjdbc.core.jdbc.core.statement.ShardingPreparedStatement.route(ShardingPreparedStatement.java:150)
        at io.shardingjdbc.core.jdbc.core.statement.ShardingPreparedStatement.execute(ShardingPreparedStatement.java:140)
        at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:62)
        at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:78)
        at sun.reflect.GeneratedMethodAccessor245.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63)
        at com.sun.proxy.$Proxy231.query(Unknown Source)
        at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
        at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:303)
        at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:154)
        at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:102)
        at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:82)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:120)

2. Abnormal Analysis

1.首先是由于我们的表是分表了:一张t_order 表分成了20张表即为:t_order_00,
t_order_01,
t_order_02,
t_order_03,
t_order_04,
t_order_05,
t_order_06,
t_order_07,
t_order_08,
t_order_09,
t_order_10,
t_order_11,
t_order_12,
t_order_13,
t_order_14,
t_order_15,
t_order_16,
t_order_17,
t_order_18,
t_order_19

Since entering the sub-table strategy when the logic table not match the physical real table (this table 20)
lead to error, I do not know that table locking

3. Solution

Look at their partitioning strategy, we are able to match the real table

Published 261 original articles · won praise 37 · Views 200,000 +

Guess you like

Origin blog.csdn.net/u014636209/article/details/102614930