sharding jdbc 3.0.0.M3 经常出现 数组下标越界异常

发布于 2022-01-07 10:25:10 字数 22365 浏览 900 评论 2

2018-09-28 10:45:47.311 ERROR 7348 --- [nio-8080-exec-6] c.a.advice.ControllerExceptionHandler    : org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: io.shardingsphere.core.exception.ShardingException: io.shardingsphere.core.exception.ShardingException: java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: 4
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: insert into tb_homework_rec (receiver_id,sender_id,homework_id,subject_name, content_short,ctime)         values                        (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)
### Cause: io.shardingsphere.core.exception.ShardingException: io.shardingsphere.core.exception.ShardingException: java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: 4
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: io.shardingsphere.core.exception.ShardingException: io.shardingsphere.core.exception.ShardingException: java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: 4
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: insert into tb_homework_rec (receiver_id,sender_id,homework_id,subject_name, content_short,ctime)         values                        (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)
### Cause: io.shardingsphere.core.exception.ShardingException: io.shardingsphere.core.exception.ShardingException: java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: 4
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
    at com.sun.proxy.$Proxy93.insert(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:278)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:57)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
    at com.sun.proxy.$Proxy121.batchInsertHomeworkReceive(Unknown Source)
    at com.aspirecn.homework.service.impl.HomeworkServiceImpl.save(HomeworkServiceImpl.java:224)
    at com.aspirecn.homework.service.impl.HomeworkServiceImpl$$FastClassBySpringCGLIB$$6e73b1b6.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
    at com.aspirecn.homework.service.impl.HomeworkServiceImpl$$EnhancerBySpringCGLIB$$4a3b9e29.save(<generated>)
    at com.aspirecn.controller.homework.HomeworkController.save(HomeworkController.java:103)
    at sun.reflect.GeneratedMethodAccessor116.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at com.aspirecn.basic.page.PageFilter.doFilter(PageFilter.java:46)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:96)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:108)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: io.shardingsphere.core.exception.ShardingException: io.shardingsphere.core.exception.ShardingException: java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: 4
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: insert into tb_homework_rec (receiver_id,sender_id,homework_id,subject_name, content_short,ctime)         values                        (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)          ,              (?, ?, ?,             ?,?,?)
### Cause: io.shardingsphere.core.exception.ShardingException: io.shardingsphere.core.exception.ShardingException: java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: 4
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:200)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:185)
    at sun.reflect.GeneratedMethodAccessor161.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)
    ... 80 more
Caused by: io.shardingsphere.core.exception.ShardingException: io.shardingsphere.core.exception.ShardingException: java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: 4
    at io.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorExceptionHandler.handleException(ExecutorExceptionHandler.java:67)
    at io.shardingsphere.core.executor.sql.execute.SQLExecuteTemplate.execute(SQLExecuteTemplate.java:82)
    at io.shardingsphere.core.executor.sql.execute.SQLExecuteTemplate.execute(SQLExecuteTemplate.java:56)
    at io.shardingsphere.core.executor.prepared.MemoryStrictlyPreparedStatementExecutor.executeCallback(MemoryStrictlyPreparedStatementExecutor.java:47)
    at io.shardingsphere.core.executor.prepared.PreparedStatementExecutor.execute(PreparedStatementExecutor.java:108)
    at io.shardingsphere.core.jdbc.core.statement.ShardingPreparedStatement.execute(ShardingPreparedStatement.java:189)
    at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:46)
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)
    at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50)
    at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
    at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
    at sun.reflect.GeneratedMethodAccessor162.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.$Proxy167.update(Unknown Source)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198)
    ... 85 more
Caused by: io.shardingsphere.core.exception.ShardingException: java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: 4
    at io.shardingsphere.core.executor.ShardingExecuteEngine.throwException(ShardingExecuteEngine.java:197)
    at io.shardingsphere.core.executor.ShardingExecuteEngine.getResults(ShardingExecuteEngine.java:116)
    at io.shardingsphere.core.executor.ShardingExecuteEngine.execute(ShardingExecuteEngine.java:88)
    at io.shardingsphere.core.executor.sql.execute.SQLExecuteTemplate.execute(SQLExecuteTemplate.java:75)
    ... 100 more
Caused by: java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: 4
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at io.shardingsphere.core.executor.ShardingExecuteEngine.getResults(ShardingExecuteEngine.java:114)
    ... 102 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 4
    at java.util.ArrayList.add(ArrayList.java:463)
    at com.alibaba.druid.pool.DruidPooledConnection.transactionRecord(DruidPooledConnection.java:729)
    at com.alibaba.druid.pool.DruidPooledStatement.transactionRecord(DruidPooledStatement.java:218)
    at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:492)
    at io.shardingsphere.core.executor.prepared.PreparedStatementExecutor$3.executeSQL(PreparedStatementExecutor.java:105)
    at io.shardingsphere.core.executor.prepared.PreparedStatementExecutor$3.executeSQL(PreparedStatementExecutor.java:101)
    at io.shardingsphere.core.executor.sql.execute.SQLExecuteCallback.execute0(SQLExecuteCallback.java:81)
    at io.shardingsphere.core.executor.sql.execute.SQLExecuteCallback.execute(SQLExecuteCallback.java:59)
    at io.shardingsphere.core.executor.sql.execute.SQLExecuteCallback.execute(SQLExecuteCallback.java:46)
    at io.shardingsphere.core.executor.ShardingExecuteEngine$1.call(ShardingExecuteEngine.java:98)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    ... 1 more

时多时少  几率大概在 百分之一到千分之一之间

 

tb_homework_rec: # 要分的表
  actual-data-nodes: masterslave.tb_homework_rec$->{0..9} # 哪个库的哪些表(子表)
  key-generator-column-name: id # 主键
  table-strategy: # 分表策略
    inline: # 行表达式策略
      shardingColumn: receiver_id # 用于分表的字段
      algorithmExpression: tb_homework_rec$->{receiver_id % 10} # 分表规则表达式

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

归途 2022-01-07 19:34:20

升级到 sharding jdbc 3.0.0 后就没再发生类似问题

绝情姑娘 2022-01-07 16:00:32

用sharding3遇到类似的indexoutofboundsexception:index:0,size:0

楼主解决了吗

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文