{"action":"closed","issue":{"url":"https://api.github.com/repos/dangdangdotcom/sharding-jdbc/issues/206","repository_url":"https://api.github.com/repos/dangdangdotcom/sharding-jdbc","labels_url":"https://api.github.com/repos/dangdangdotcom/sharding-jdbc/issues/206/labels{/name}","comments_url":"https://api.github.com/repos/dangdangdotcom/sharding-jdbc/issues/206/comments","events_url":"https://api.github.com/repos/dangdangdotcom/sharding-jdbc/issues/206/events","html_url":"https://github.com/dangdangdotcom/sharding-jdbc/issues/206","id":194537940,"number":206,"title":"并发执行sql时报了IndexOutOfBoundsException","user":{"login":"ben1247","id":8873346,"avatar_url":"https://avatars.githubusercontent.com/u/8873346?v=3","gravatar_id":"","url":"https://api.github.com/users/ben1247","html_url":"https://github.com/ben1247","followers_url":"https://api.github.com/users/ben1247/followers","following_url":"https://api.github.com/users/ben1247/following{/other_user}","gists_url":"https://api.github.com/users/ben1247/gists{/gist_id}","starred_url":"https://api.github.com/users/ben1247/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ben1247/subscriptions","organizations_url":"https://api.github.com/users/ben1247/orgs","repos_url":"https://api.github.com/users/ben1247/repos","events_url":"https://api.github.com/users/ben1247/events{/privacy}","received_events_url":"https://api.github.com/users/ben1247/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-09T08:20:43Z","updated_at":"2016-12-10T00:41:18Z","closed_at":"2016-12-10T00:41:18Z","body":"1. 现象：local环境不报错，线上环境执行10次，平均6次成功，4次失败\r\n2. 使用sjdbc+druid+mybatis\r\n3. mybatis.xml 代码：\r\n<select id=\"statFansRegion\"\r\n            parameterType=\"com.shuyun.wxcrm.fans.model.FansStatSearch\"\r\n            resultType=\"com.shuyun.wxcrm.fans.model.FansRegionStat\">\r\n        SELECT\r\n        country,\r\n        province,\r\n        count(openid)AS count\r\n        FROM\r\n        wechat_user_info\r\n        WHERE\r\n        tenant_id = #{tenantId}\r\n        AND wechat_public_number = #{wechatPublicNumber}\r\n        AND subscribe = 1\r\n        AND country is not null\r\n        AND province is not NULL\r\n        AND country != ''\r\n        and province != ''\r\n        GROUP BY country,province\r\n        order BY count DESC\r\n        <if test=\"pageNum != null\">\r\n            LIMIT #{offset} , #{pageSize}\r\n        </if>\r\n    </select>\r\n\r\n3. 报错信息：\r\n\r\nCaused by: org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database.  Cause: java.lang.IndexOutOfBoundsException: Index: 2, Size: 0\r\n### The error may exist in com/shuyun/wxcrm/fans/mapper/WechatUserInfoMapper.xml\r\n### The error may involve com.shuyun.wxcrm.fans.mapper.WechatUserInfoMapper.statFansRegion-Inline\r\n### The error occurred while setting parameters\r\n### SQL: SELECT         \r\n            country, province, count(openid)AS count         \r\n        FROM         \r\n            wechat_user_info         \r\n        WHERE         \r\n            tenant_id = ?         \r\n            AND wechat_public_number = ?         \r\n            AND subscribe = 1         \r\n            AND country is not null         \r\n            AND province is not NULL         \r\n            AND country != ''         \r\n            and province != '' \r\n            GROUP BY country,province         \r\n            order BY count DESC                       \r\n            LIMIT ? , ?\r\n### Cause: java.lang.IndexOutOfBoundsException: Index: 2, Size: 0\r\n    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) ~[wxcrm-server-fans-1.0-SNAPSHOT.jar:na]\r\n    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150) ~[wxcrm-server-fans-1.0-SNAPSHOT.jar:na]\r\n    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) ~[wxcrm-server-fans-1.0-SNAPSHOT.jar:na]\r\n    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_91]\r\n    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_91]\r\n    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_91]\r\n    at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_91]\r\n    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:434) ~[wxcrm-server-fans-1.0-SNAPSHOT.jar:na]\r\n    ... 67 common frames omitted\r\nCaused by: java.lang.IndexOutOfBoundsException: Index: 2, Size: 0\r\n    at java.util.ArrayList.rangeCheck(Unknown Source) ~[na:1.8.0_91]\r\n    at java.util.ArrayList.get(Unknown Source) ~[na:1.8.0_91]\r\n    at com.dangdang.ddframe.rdb.sharding.jdbc.util.ParameterList.set(ParameterList.java:82) ~[wxcrm-server-fans-1.0-SNAPSHOT.jar:na]\r\n    at com.dangdang.ddframe.rdb.sharding.parser.result.merger.Limit.replaceParameters(Limit.java:71) ~[wxcrm-server-fans-1.0-SNAPSHOT.jar:na]\r\n    at com.dangdang.ddframe.rdb.sharding.router.SQLRouteEngine.routeSQL(SQLRouteEngine.java:105) ~[wxcrm-server-fans-1.0-SNAPSHOT.jar:na]\r\n    at com.dangdang.ddframe.rdb.sharding.router.PreparedSQLRouter.route(PreparedSQLRouter.java:56) ~[wxcrm-server-fans-1.0-SNAPSHOT.jar:na]\r\n    at com.dangdang.ddframe.rdb.sharding.jdbc.ShardingPreparedStatement.routeSQL(ShardingPreparedStatement.java:162) ~[wxcrm-server-fans-1.0-SNAPSHOT.jar:na]\r\n    at com.dangdang.ddframe.rdb.sharding.jdbc.ShardingPreparedStatement.execute(ShardingPreparedStatement.java:112) ~[wxcrm-server-fans-1.0-SNAPSHOT.jar:na]\r\n    at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:63) ~[wxcrm-server-fans-1.0-SNAPSHOT.jar:na]\r\n    at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79) ~[wxcrm-server-fans-1.0-SNAPSHOT.jar:na]\r\n    at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63) ~[wxcrm-server-fans-1.0-SNAPSHOT.jar:na]\r\n    at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324) ~[wxcrm-server-fans-1.0-SNAPSHOT.jar:na]\r\n    at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) ~[wxcrm-server-fans-1.0-SNAPSHOT.jar:na]\r\n    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) ~[wxcrm-server-fans-1.0-SNAPSHOT.jar:na]\r\n    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83) ~[wxcrm-server-fans-1.0-SNAPSHOT.jar:na]\r\n    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) ~[wxcrm-server-fans-1.0-SNAPSHOT.jar:na]\r\n    ... 73 common frames omitted\r\n"}}
{"actor":{"display_login":"hanahmily"}}