MyCATApache / Mycat-Server

GNU General Public License v2.0
9.5k stars 3.85k forks source link

批量插入5000条数据报错 #2046

Open luyaotc opened 5 years ago

luyaotc commented 5 years ago

使用druid链接mycat链接mysql数据库,批量插入5000条数据(在一个insert语句里)

please help

druid报错: 2018-11-01 02:39:44,802 ERROR [com.alibaba.druid.pool.DruidDataSource]- discard connection com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 9 milliseconds ago. The last packet sent successfully to the server was 10 milliseconds ago. at sun.reflect.GeneratedConstructorAccessor2160.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:408) at com.mysql.jdbc.Util.handleNewInstance(Util.java:409) at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1127) at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3983) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2596) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2776) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2838) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082) at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1307) at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2931) at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:440) at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2929) at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.execute(PreparedStatementProxyImpl.java:131) at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:493) at sun.reflect.GeneratedMethodAccessor101.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:62) at com.sun.proxy.$Proxy154.execute(Unknown Source) at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:44) at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:69) at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:48) at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:105) at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:71) at sun.reflect.GeneratedMethodAccessor11570.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62) at com.sun.proxy.$Proxy3200.update(Unknown Source) at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:152) at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:141) at sun.reflect.GeneratedMethodAccessor11747.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:386) at com.sun.proxy.$Proxy3082.insert(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:253) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:51) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52) at com.sun.proxy.$Proxy3132.insertData(Unknown Source) at com.irongbei.modules.zsph.service.RepayHistoryService.getList(RepayHistoryService.java:292) at com.irongbei.modules.zsph.service.RepayHistoryService$$FastClassBySpringCGLIB$$6530af01.invoke() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:747) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.transaction.interceptor.TransactionInterceptor$$Lambda$2607/628266835.proceedWithInvocation(Unknown Source) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689) at com.irongbei.modules.zsph.service.RepayHistoryService$$EnhancerBySpringCGLIB$$d422f51f.getList() at com.irongbei.modules.zsph.service.RepayHistoryService$$FastClassBySpringCGLIB$$6530af01.invoke() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:747) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.transaction.interceptor.TransactionInterceptor$$Lambda$2607/628266835.proceedWithInvocation(Unknown Source) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689) at com.irongbei.modules.zsph.service.RepayHistoryService$$EnhancerBySpringCGLIB$$adc6d833.getList() at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)

mycat报错: INFO | jvm 1 | 2018/11/01 02:33:17 | 2018-11-01 02:33:17,009 [WARN ][$_NIOREACTOR-7-RW] ServerConnection [id=1, schema=credit, host=172.19.0.1, user=mycat,txIsolation=3, autocommit=true, schema=credit]set session transaction read write is not recoginized and ignored (io.mycat.server.handler.SetHandler:SetHandler.java:159) INFO | jvm 1 | 2018/11/01 02:36:45 | 2018-11-01 02:36:45,496 [INFO ][Timer1] create connections ,because idle connection not enough ,cur is 5, minCon is 10 for hostS1 (io.mycat.backend.datasource.PhysicalDatasource:PhysicalDatasource.java:299) INFO | jvm 1 | 2018/11/01 02:36:45 | 2018-11-01 02:36:45,500 [INFO ][$_NIOREACTOR-4-RW] connectionAcquired MySQLConnection [id=39, lastTime=1541011005495, user=mycat, schema=credit, old shema=credit, borrowed=false, fromSlaveDB=true, threadId=94877, charset=utf8, txIsolation=3, autocommit=true, attachment=null, respHandler=null, host=rr-bp1i4vte50uvcnb10.mysql.rds.aliyuncs.com, port=3306, statusSync=null, writeQueue=0, modifiedSQLExecuted=false] (io.mycat.backend.mysql.nio.handler.NewConnectionRespHandler:NewConnectionRespHandler.java:45) INFO | jvm 1 | 2018/11/01 02:39:44 | 2018-11-01 02:39:44,800 [WARN ][$_NIOREACTOR-0-RW] caught err: java.lang.NullPointerException INFO | jvm 1 | 2018/11/01 02:39:44 | at io.mycat.net.AbstractConnection.ensureFreeSpaceOfReadBuffer(AbstractConnection.java:387) INFO | jvm 1 | 2018/11/01 02:39:44 | at io.mycat.net.AbstractConnection.onReadData(AbstractConnection.java:366) INFO | jvm 1 | 2018/11/01 02:39:44 | at io.mycat.net.NIOSocketWR.asynRead(NIOSocketWR.java:190) INFO | jvm 1 | 2018/11/01 02:39:44 | at io.mycat.net.AbstractConnection.asynRead(AbstractConnection.java:273) INFO | jvm 1 | 2018/11/01 02:39:44 | at io.mycat.net.NIOReactor$RW.run(NIOReactor.java:102) INFO | jvm 1 | 2018/11/01 02:39:44 | at java.lang.Thread.run(Thread.java:745) INFO | jvm 1 | 2018/11/01 02:39:44 | (io.mycat.net.NIOReactor$RW:NIOReactor.java:107) INFO | jvm 1 | 2018/11/01 02:39:44 | 2018-11-01 02:39:44,801 [INFO ][$_NIOREACTOR-0-RW] close connection,reason:program err:java.lang.NullPointerException ,ServerConnection [id=18, schema=credit, host=172.19.0.12, user=mycat,txIsolation=3, autocommit=false, schema=credit] (io.mycat.net.AbstractConnection:AbstractConnection.java:508) INFO | jvm 1 | 2018/11/01 02:39:44 | 2018-11-01 02:39:44,805 [INFO ][$_NIOREACTOR-5-RW] ServerConnection [id=22, schema=credit, host=172.19.0.12, user=mycat,txIsolation=3, autocommit=true, schema=credit]'mycat' login success (io.mycat.net.handler.FrontendAuthenticator:FrontendAuthenticator.java:194) INFO | jvm 1 | 2018/11/01 02:41:45 | 2018-11-01 02:41:45,496 [INFO ][Timer0] too many ilde cons ,close some for datasouce hostS1 (io.mycat.backend.datasource.PhysicalDatasource:PhysicalDatasource.java:280) INFO | jvm 1 | 2018/11/01 02:41:45 | 2018-11-01 02:41:45,496 [INFO ][Timer0] close connection,reason:too many idle con ,MySQLConnection [id=37, lastTime=1541011005495, user=mycat, schema=credit, old shema=credit, borrowed=false, fromSlaveDB=true, threadId=94356, charset=utf8, txIsolation=3, autocommit=true, attachment=null, respHandler=null, host=rr-bp1i4vte50uvcnb10.mysql.rds.aliyuncs.com, port=3306, statusSync=null, writeQueue=0, modifiedSQLExecuted=false] (io.mycat.net.AbstractConnection:AbstractConnection.java:508) INFO | jvm 1 | 2018/11/01 02:41:45 | 2018-11-01 02:41:45,496 [INFO ][Timer0] close connection,reason:too many idle con ,MySQLConnection [id=36, lastTime=1541011005495, user=mycat, schema=credit, old shema=credit, borrowed=false, fromSlaveDB=true, threadId=94355, charset=utf8, txIsolation=3, autocommit=true, attachment=null, respHandler=null, host=rr-bp1i4vte50uvcnb10.mysql.rds.aliyuncs.com, port=3306, statusSync=null, writeQueue=0, modifiedSQLExecuted=false] (io.mycat.net.AbstractConnection:AbstractConnection.java:508) INFO | jvm 1 | 2018/11/01 02:42:01 | 2018-11-01 02:42:01,643 [WARN ][$_NIOREACTOR-0-RW] ServerConnection [id=2, schema=credit, host=172.19.0.1, user=mycat,txIsolation=3, autocommit=true, schema=credit]set session transaction read only is not recoginized and ignored (io.mycat.server.handler.SetHandler:SetHandler.java:159)

codingframer commented 5 years ago

我也遇到这个问题了