mysql> select c.id, c.name, o.id from customer1 c, orders1 o where c.id=o.customer_id and c.id=10000;
+-------+------+-------+
| id | name | id |
+-------+------+-------+
| 10000 | aaa | 90000 |
+-------+------+-------+
1 row in set (0.00 sec)
select语句对应的log如下,
1
2
3
4
5
6
7
8
9
10
11
12
01/3118:12:33.823 DEBUG [$_NIOREACTOR-0-RW] (EnchachePool.java:76) -SQLRouteCache miss cache ,key:TESTDBselect c.id, c.name, o.id from customer1 c, orders1 o where c.id=o.customer_id and c.id=10000
01/3118:12:33.825 DEBUG [$_NIOREACTOR-0-RW] (RouterUtil.java:951) -try to find cache by primary key
01/3118:12:33.825 DEBUG [$_NIOREACTOR-0-RW] (EnchachePool.java:76) -TableID2DataNodeCache.TESTDB_CUSTOMER1 miss cache ,key:10000
01/3118:12:33.826 DEBUG [$_NIOREACTOR-0-RW] (EnchachePool.java:59) -SQLRouteCache add cache ,key:TESTDBselect c.id, c.name, o.id from customer1 c, orders1 o where c.id=o.customer_id and c.id=10000 value:select c.id, c.name, o.id from customer1 c, orders1 o where c.id=o.customer_id and c.id=10000, route={
1 -> dn2{select c.id, c.name, o.id from customer1 c, orders1 o where c.id=o.customer_id and c.id=10000}
}
01/3118:12:33.826 DEBUG [$_NIOREACTOR-0-RW] (NonBlockingSession.java:113) -ServerConnection [id=1, schema=TESTDB, host=192.168.1.6, user=test,txIsolation=3, autocommit=true, schema=TESTDB]select c.id, c.name, o.id from customer1 c, orders1 o where c.id=o.customer_id and c.id=10000, route={
1 -> dn2{select c.id, c.name, o.id from customer1 c, orders1 o where c.id=o.customer_id and c.id=10000}
} rrs
01/3118:12:33.826 DEBUG [$_NIOREACTOR-0-RW] (PhysicalDBPool.java:452) -select read source hostM1 for dataHost:localhost1
01/3118:12:33.827 DEBUG [$_NIOREACTOR-3-RW] (NonBlockingSession.java:229) -release connection MySQLConnection [id=7, lastTime=1454235153813, user=root, schema=db2, old shema=db2, borrowed=true, fromSlaveDB=false, threadId=2, charset=latin1, txIsolation=3, autocommit=true, attachment=dn2{select c.id, c.name, o.id from customer1 c, orders1 o where c.id=o.customer_id and c.id=10000}, respHandler=SingleNodeHandler [node=dn2{select c.id, c.name, o.id from customer1 c, orders1 o where c.id=o.customer_id and c.id=10000}, packetId=6], host=192.168.1.6, port=3306, statusSync=null, writeQueue=0, modifiedSQLExecuted=false]
mysql> select c.id, c.name, o.id from customer2 c, orders2 o where c.id=o.customer_id and c.name='aaa';
+-------+------+-------+
| id | name | id |
+-------+------+-------+
| 10000 | aaa | 90000 |
+-------+------+-------+
1 row in set (0.00 sec)
select语句对应的log如下,
1
2
3
4
5
6
7
8
9
10
11
12
01/3119:32:55.975 DEBUG [$_NIOREACTOR-0-RW] (ServerQueryHandler.java:56) -ServerConnection [id=1, schema=TESTDB, host=192.168.1.6, user=test,txIsolation=3, autocommit=true, schema=TESTDB]select c.id, c.name, o.id from customer2 c, orders2 o where c.id=o.customer_id and c.name='aaa'
01/3119:32:55.976 DEBUG [$_NIOREACTOR-0-RW] (EnchachePool.java:70) -SQLRouteCache hit cache ,key:TESTDBselect c.id, c.name, o.id from customer2 c, orders2 o where c.id=o.customer_id and c.name='aaa'
01/3119:32:55.976 DEBUG [$_NIOREACTOR-0-RW] (NonBlockingSession.java:113) -ServerConnection [id=1, schema=TESTDB, host=192.168.1.6, user=test,txIsolation=3, autocommit=true, schema=TESTDB]select c.id, c.name, o.id from customer2 c, orders2 o where c.id=o.customer_id and c.name='aaa', route={
1 -> dn2{select c.id, c.name, o.id from customer2 c, orders2 o where c.id=o.customer_id and c.name='aaa'}
} rrs
01/3119:32:55.976 DEBUG [$_NIOREACTOR-0-RW] (PhysicalDBPool.java:452) -select read source hostM1 for dataHost:localhost1
01/3119:32:55.977 DEBUG [$_NIOREACTOR-3-RW] (NonBlockingSession.java:229) -release connection MySQLConnection [id=3, lastTime=1454239975957, user=root, schema=db2, old shema=db2, borrowed=true, fromSlaveDB=false, threadId=26, charset=latin1, txIsolation=3, autocommit=true, attachment=dn2{select c.id, c.name, o.id from customer2 c, orders2 o where c.id=o.customer_id and c.name='aaa'}, respHandler=SingleNodeHandler [node=dn2{select c.id, c.name, o.id from customer2 c, orders2 o where c.id=o.customer_id and c.name='aaa'}, packetId=6], host=192.168.1.6, port=3306, statusSync=null, writeQueue=0, modifiedSQLExecuted=false]
01/31 21:40:52.308 DEBUG [$_NIOREACTOR-0-RW] (ServerQueryHandler.java:56) -ServerConnection [id=1, schema=TESTDB, host=192.168.1.6, user=test,txIsolation=3, autocommit=true, schema=TESTDB]select * from test_d2 where id between20000and30000
01/3121:40:52.308 DEBUG [$_NIOREACTOR-0-RW] (EnchachePool.java:76) -SQLRouteCache miss cache ,key:TESTDBselect * from test_d2 where id between20000and30000
01/3121:40:52.309 WARN [$_NIOREACTOR-0-RW] (ServerConnection.java:209) -ServerConnection [id=1, schema=TESTDB, host=192.168.1.6, user=test,txIsolation=3, autocommit=true, schema=TESTDB]select * from test_d2 where id between20000and30000 err:java.lang.NullPointerException
java.lang.NullPointerException
at org.opencloudb.route.util.RouterUtil.findRouteWithcConditionsForTables(RouterUtil.java:1007)
at org.opencloudb.route.util.RouterUtil.tryRouteForOneTable(RouterUtil.java:896)
at org.opencloudb.route.util.RouterUtil.tryRouteForTables(RouterUtil.java:780)
at org.opencloudb.parser.druid.impl.DruidSelectParser.tryRoute(DruidSelectParser.java:376)
at org.opencloudb.parser.druid.impl.DruidSelectParser.changeSql(DruidSelectParser.java:264)
at org.opencloudb.parser.druid.impl.DefaultDruidParser.parser(DefaultDruidParser.java:66)
at org.opencloudb.route.impl.DruidMycatRouteStrategy.routeNormalSqlWithAST(DruidMycatRouteStrategy.java:64)
at org.opencloudb.route.impl.AbstractRouteStrategy.route(AbstractRouteStrategy.java:76)
at org.opencloudb.route.RouteService.route(RouteService.java:116)
at org.opencloudb.server.ServerConnection.routeEndExecuteSQL(ServerConnection.java:201)
at org.opencloudb.server.ServerConnection.execute(ServerConnection.java:154)
at org.opencloudb.server.handler.SelectHandler.handle(SelectHandler.java:102)
at org.opencloudb.server.ServerQueryHandler.query(ServerQueryHandler.java:77)
at org.opencloudb.net.FrontendConnection.query(FrontendConnection.java:308)
at org.opencloudb.net.handler.FrontendCommandHandler.handle(FrontendCommandHandler.java:71)
at org.opencloudb.net.FrontendConnection.rawHandle(FrontendConnection.java:435)
at org.opencloudb.net.FrontendConnection.handle(FrontendConnection.java:417)
at org.opencloudb.net.AbstractConnection.onReadData(AbstractConnection.java:313)
at org.opencloudb.net.NIOSocketWR.asynRead(NIOSocketWR.java:186)
at org.opencloudb.net.AbstractConnection.asynRead(AbstractConnection.java:274)
at org.opencloudb.net.NIOReactor$RW.run(NIOReactor.java:96)