Mycat在使用注解ShareJoin遇到的错误

版本Mycat-server-1.4-RC-20150823180032-linux.tar和Mycat-server-1.4-release-20151019230038-linux.tar.gz

在执行跨库join时遇到的错误如下:

_11/2400:48:26.701   INFO [$_NIOREACTOR-0-RW](FrontendAuthenticator.java:164) -ServerConnection [id=1, schema=null,host=192.168.40.1, user=bin,txIsolation=3, autocommit=true, schema=null]'bin'login success

11/2400:48:26.843   INFO [$_NIOREACTOR-0-RW](JoinParser.java:70) -SQL: SELECT a.*,m.* from member m JOIN member_addr awhere m.id=a.member_id

11/2400:48:26.918   INFO [$_NIOREACTOR-0-RW](ShareJoin.java:150) -Catlet exec:dn1,dn2, sql:select * from member

11/2400:48:26.924  ERROR [$_NIOREACTOR-0-RW](DruidMycatRouteStrategy.java:46) -DruidMycatRouteStrategyError

com.alibaba.druid.sql.parser.ParserException:syntax error, expect RPAREN, actual IDENTIFIER e

       atcom.alibaba.druid.sql.parser.SQLExprParser.accept(SQLExprParser.java:1471)

       atcom.alibaba.druid.sql.parser.SQLExprParser.inRest(SQLExprParser.java:1074)

       atcom.alibaba.druid.sql.parser.SQLExprParser.exprRest(SQLExprParser.java:135)

       atcom.alibaba.druid.sql.parser.SQLExprParser.expr(SQLExprParser.java:125)

       atcom.alibaba.druid.sql.parser.SQLSelectParser.expr(SQLSelectParser.java:457)

       atcom.alibaba.druid.sql.parser.SQLSelectParser.parseWhere(SQLSelectParser.java:237)

       atcom.alibaba.druid.sql.dialect.mysql.parser.MySqlSelectParser.query(MySqlSelectParser.java:134)

       atcom.alibaba.druid.sql.parser.SQLSelectParser.select(SQLSelectParser.java:60)

       atcom.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser.parseSelect(MySqlStatementParser.java:196)

       atcom.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:145)

       atcom.alibaba.druid.sql.parser.SQLStatementParser.parseStatement(SQLStatementParser.java:1658)

       atorg.opencloudb.route.impl.DruidMycatRouteStrategy.routeNormalSqlWithAST(DruidMycatRouteStrategy.java:43)

       atorg.opencloudb.route.impl.AbstractRouteStrategy.route(AbstractRouteStrategy.java:61)

       atdemo.catlets.ShareJoin.getRoute(ShareJoin.java:114)

       atdemo.catlets.ShareJoin.createQryJob(ShareJoin.java:225)

       atdemo.catlets.ShareJoin.endJobInput(ShareJoin.java:185)

       atdemo.catlets.ShareDBJoinHandler.finished(ShareJoin.java:324)

       atorg.opencloudb.sqlengine.SQLJob.doFinished(SQLJob.java:103)

       atorg.opencloudb.sqlengine.SQLJob.rowEofResponse(SQLJob.java:153)

       atorg.opencloudb.mysql.nio.MySQLConnectionHandler.handleRowEofPacket(MySQLConnectionHandler.java:223)

       atorg.opencloudb.mysql.nio.MySQLConnectionHandler.handleData(MySQLConnectionHandler.java:131)

       atorg.opencloudb.net.handler.BackendAsyncHandler.offerData(BackendAsyncHandler.java:36)

       atorg.opencloudb.mysql.nio.MySQLConnectionHandler.handle(MySQLConnectionHandler.java:79)

       atorg.opencloudb.net.AbstractConnection.handle(AbstractConnection.java:257)

       atorg.opencloudb.net.AbstractConnection.onReadData(AbstractConnection.java:307)

       atorg.opencloudb.net.NIOSocketWR.asynRead(NIOSocketWR.java:186)

       atorg.opencloudb.net.AbstractConnection.asynRead(AbstractConnection.java:268)

       atorg.opencloudb.net.NIOReactor$RW.run(NIOReactor.java:96)

       at java.lang.Thread.run(Thread.java:745)

11/2400:48:26.940   INFO [$_NIOREACTOR-0-RW](ShareJoin.java:229) -SQLParallJob:dn1,dn2, sql:select * from member_addr wheremember_id in(f21daa38-157d-4e05-9e64-03a284e45d71,4e15016e-d6d3-4641-b0e0-024524c3d354,9dfd5c4c-4a70-4d51-a19a-32b68cd422dc,4ba5382a-a1ba-4486-bdf6-7f2e1381cefd,2f6266c3-b853-46d9-8cf7-785ff0b4c862,29621cbc-1556-4354-b2eb-30daaafdabad,b6eb156f-489b-4a40-b88e-41d870a47289,6f4ed84e-4d8d-41aa-a611-877084bef85d,4a98b36e-d58a-4b1b-84c4-44da278c500b,0950b2da-5900-4edc-9057-2e254bff168f)

11/2400:48:26.941   INFO [$_NIOREACTOR-0-RW](SQLJob.java:120) -error response Illegal double '4e15016' value found duringparsing from of sql :select * from member_addr where member_id in(f21daa38-157d-4e05-9e64-03a284e45d71,4e15016e-d6d3-4641-b0e0-024524c3d354,9dfd5c4c-4a70-4d51-a19a-32b68cd422dc,4ba5382a-a1ba-4486-bdf6-7f2e1381cefd,2f6266c3-b853-46d9-8cf7-785ff0b4c862,29621cbc-1556-4354-b2eb-30daaafdabad,b6eb156f-489b-4a40-b88e-41d870a47289,6f4ed84e-4d8d-41aa-a611-877084bef85d,4a98b36e-d58a-4b1b-84c4-44da278c500b,0950b2da-5900-4edc-9057-2e254bff168f)  at con:MySQLConnection [id=16,lastTime=1448354906924, schema=db1, old shema=db1, borrowed=true,fromSlaveDB=false, threadId=2415, charset=latin1, txIsolation=0,autocommit=true, attachment=dn1{select * from member_addr where member_id in(f21daa38-157d-4e05-9e64-03a284e45d71,4e15016e-d6d3-4641-b0e0-024524c3d354,9dfd5c4c-4a70-4d51-a19a-32b68cd422dc,4ba5382a-a1ba-4486-bdf6-7f2e1381cefd,2f6266c3-b853-46d9-8cf7-785ff0b4c862,29621cbc-1556-4354-b2eb-30daaafdabad,b6eb156f-489b-4a40-b88e-41d870a47289,6f4ed84e-4d8d-41aa-a611-877084bef85d,4a98b36e-d58a-4b1b-84c4-44da278c500b,0950b2da-5900-4edc-9057-2e254bff168f)}, respHandler=SQLJob [ id=3,dataNodeOrDatabase=dn1,sql=select * frommember_addr where member_id in(f21daa38-157d-4e05-9e64-03a284e45d71,4e15016e-d6d3-4641-b0e0-024524c3d354,9dfd5c4c-4a70-4d51-a19a-32b68cd422dc,4ba5382a-a1ba-4486-bdf6-7f2e1381cefd,2f6266c3-b853-46d9-8cf7-785ff0b4c862,29621cbc-1556-4354-b2eb-30daaafdabad,b6eb156f-489b-4a40-b88e-41d870a47289,6f4ed84e-4d8d-41aa-a611-877084bef85d,4a98b36e-d58a-4b1b-84c4-44da278c500b,0950b2da-5900-4edc-9057-2e254bff168f), jobHandler=demo.catlets.ShareRowOutPutDataHandler@18f67fc],host=192.168.40.147, port=3306, statusSync=null, writeQueue=0,modifiedSQLExecuted=false]

11/2400:48:26.941   INFO [$_NIOREACTOR-0-RW](SQLJob.java:120) -error response Illegal double '4e15016' value found duringparsing from of sql :select * from member_addr where member_id in(f21daa38-157d-4e05-9e64-03a284e45d71,4e15016e-d6d3-4641-b0e0-024524c3d354,9dfd5c4c-4a70-4d51-a19a-32b68cd422dc,4ba5382a-a1ba-4486-bdf6-7f2e1381cefd,2f6266c3-b853-46d9-8cf7-785ff0b4c862,29621cbc-1556-4354-b2eb-30daaafdabad,b6eb156f-489b-4a40-b88e-41d870a47289,6f4ed84e-4d8d-41aa-a611-877084bef85d,4a98b36e-d58a-4b1b-84c4-44da278c500b,0950b2da-5900-4edc-9057-2e254bff168f)  at con:MySQLConnection [id=10,lastTime=1448354906924, schema=db1, old shema=db1, borrowed=true,fromSlaveDB=false, threadId=2194, charset=latin1, txIsolation=0, autocommit=true,attachment=dn2{select * from member_addr where member_id in(f21daa38-157d-4e05-9e64-03a284e45d71,4e15016e-d6d3-4641-b0e0-024524c3d354,9dfd5c4c-4a70-4d51-a19a-32b68cd422dc,4ba5382a-a1ba-4486-bdf6-7f2e1381cefd,2f6266c3-b853-46d9-8cf7-785ff0b4c862,29621cbc-1556-4354-b2eb-30daaafdabad,b6eb156f-489b-4a40-b88e-41d870a47289,6f4ed84e-4d8d-41aa-a611-877084bef85d,4a98b36e-d58a-4b1b-84c4-44da278c500b,0950b2da-5900-4edc-9057-2e254bff168f)}, respHandler=SQLJob [ id=4,dataNodeOrDatabase=dn2,sql=select * from member_addrwhere member_id in(f21daa38-157d-4e05-9e64-03a284e45d71,4e15016e-d6d3-4641-b0e0-024524c3d354,9dfd5c4c-4a70-4d51-a19a-32b68cd422dc,4ba5382a-a1ba-4486-bdf6-7f2e1381cefd,2f6266c3-b853-46d9-8cf7-785ff0b4c862,29621cbc-1556-4354-b2eb-30daaafdabad,b6eb156f-489b-4a40-b88e-41d870a47289,6f4ed84e-4d8d-41aa-a611-877084bef85d,4a98b36e-d58a-4b1b-84c4-44da278c500b,0950b2da-5900-4edc-9057-2e254bff168f), jobHandler=demo.catlets.ShareRowOutPutDataHandler@18f67fc],host=192.168.40.148, port=3306, statusSync=null, writeQueue=0,modifiedSQLExecuted=false]

11/2400:48:26.941   INFO [$_NIOREACTOR-0-RW](EngineCtx.java:171) -all job finished for front connection: ServerConnection [id=1, schema=YITIAN,host=192.168.40.1, user=bin,txIsolation=3, autocommit=true, schema=YITIAN]

11/2400:48:26.942   INFO [$_NIOREACTOR-0-RW](EngineCtx.java:159) -write  eof,packgId:1

11/2400:48:26.942   INFO [$_NIOREACTOR-0-RW](ShareJoin.java:159) -发送数据OK


解决办法:

修改源码demo.catlets.ShareJoin中的createQryJob方法

    private void createQryJob(int batchSize) {    
        int count = 0;
        Map<String, byte[]> batchRows = new ConcurrentHashMap<String, byte[]>();
        String theId = null;
        StringBuilder sb = new StringBuilder().append('(');
        String svalue="";
        for(Map.Entry<String,String> e: ids.entrySet() ){
            theId=e.getKey();
            batchRows.put(theId, rows.remove(theId));
            if (!svalue.equals(e.getValue())){
              sb.append("'"+e.getValue()+"'").append(',');
            }
            svalue=e.getValue();
            if (count++ > batchSize) {
                break;
            }            
        }
        /*
        while ((theId = ids.poll()) != null) {
            batchRows.put(theId, rows.remove(theId));
            sb.append(theId).append(',');
            if (count++ > batchSize) {
                break;
            }
        }
        */
        if (count == 0) {
            return;
        }
        jointTableIsData=true;
        sb.deleteCharAt(sb.length() - 1).append(')');
        String sql = String.format(joinParser.getChildSQL(), sb);
        //if (!childRoute){
          getRoute(sql);
         //childRoute=true;
        //}

         ids.clear();//清除上一次查询的id结果集,源码中没有这      //句,导致跨分片查询失败

        ctx.executeNativeSQLParallJob(getDataNodes(),sql, new ShareRowOutPutDataHandler(this,fields,joinindex,joinParser.getJoinRkey(), batchRows));
        EngineCtx.LOGGER.info("SQLParallJob:"+getDataNode(getDataNodes())+" sql:" + sql);        
    } 


如上所示,加粗加大的那行代码是错误引起的原因,那是已经改正后的


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值