ClickHouse-Native-JDBC icon indicating copy to clipboard operation
ClickHouse-Native-JDBC copied to clipboard

Connection is currently waiting for an insert operation, check your previous InsertStatement.

Open phenix-gao opened this issue 3 years ago • 7 comments

Environment

  • OS version: centos
  • JDK version:1.8
  • ClickHouse Server version: 20.7.1.1
  • ClickHouse Native JDBC version:2.5.4
  • (Optional) Spark version: N/A
  • (Optional) Other components' version: N/A
  • Sprintboot+Mybatis+ClickHouse-Native-JDBC
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.minimum-idle=5
spring.datasource.hikari.maximum-pool-size=20
spring.datasource.hikari.auto-commit=true
spring.datasource.hikari.idle-timeout=30000
spring.datasource.hikari.pool-name=DatebookHikariCP
spring.datasource.hikari.max-lifetime=1800000
spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.connection-test-query=SELECT 1
spring.datasource.dynamic.primary=master
spring.datasource.dynamic.datasource.master.url=***
spring.datasource.dynamic.datasource.master.username=***
spring.datasource.dynamic.datasource.master.password=****
spring.datasource.dynamic.datasource.master.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.dynamic.datasource.ck.url=*****
spring.datasource.dynamic.datasource.ck.username=****
spring.datasource.dynamic.datasource.ck.password=****
spring.datasource.dynamic.datasource.ck.driver-class-name=com.github.housepower.jdbc.ClickHouseDriver

When I use JdbcTemplate batch insert to clickhouse,running for a few minutes, the following error occurs. How do I solve it?

Error logs

java.sql.SQLException: Connection is currently waiting for an insert operation, check your previous InsertStatement.
        at com.github.housepower.jdbc.misc.Validate.isTrue(Validate.java:41)
        at com.github.housepower.jdbc.ClickHouseConnection.sendQueryRequest(ClickHouseConnection.java:269)
        at com.github.housepower.jdbc.statement.ClickHouseStatement.executeUpdate(ClickHouseStatement.java:92)
        at com.github.housepower.jdbc.statement.ClickHouseStatement.executeQuery(ClickHouseStatement.java:100)
        at com.github.housepower.jdbc.statement.ClickHouseStatement.execute(ClickHouseStatement.java:69)
        at com.alibaba.druid.filter.FilterChainImpl.statement_execute(FilterChainImpl.java:3010)
        at com.alibaba.druid.filter.FilterAdapter.statement_execute(FilterAdapter.java:2484)
        at com.alibaba.druid.filter.FilterEventAdapter.statement_execute(FilterEventAdapter.java:188)
        at com.alibaba.druid.filter.FilterChainImpl.statement_execute(FilterChainImpl.java:3008)
        at com.alibaba.druid.filter.FilterAdapter.statement_execute(FilterAdapter.java:2484)
        at com.alibaba.druid.filter.FilterEventAdapter.statement_execute(FilterEventAdapter.java:188)
        at com.alibaba.druid.filter.FilterChainImpl.statement_execute(FilterChainImpl.java:3008)
        at com.alibaba.druid.proxy.jdbc.StatementProxyImpl.execute(StatementProxyImpl.java:147)
        at com.alibaba.druid.pool.DruidPooledStatement.execute(DruidPooledStatement.java:632)
        at org.springframework.jdbc.core.JdbcTemplate$1ExecuteStatementCallback.doInStatement(JdbcTemplate.java:409)
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:376)
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:418)
        at com.github.modules.device.service.impl.AndroidServiceImpl.saveBatch(AndroidServiceImpl.java:79)
        at com.baomidou.mybatisplus.extension.service.IService.saveBatch(IService.java:58)
        at com.baomidou.mybatisplus.extension.service.IService$$FastClassBySpringCGLIB$$f8525d18.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
        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:186)
        at com.baomidou.dynamic.datasource.aop.DynamicDataSourceAnnotationInterceptor.invoke(DynamicDataSourceAnnotationInterceptor.java:52)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)

Steps to reproduce

Other descriptions

phenix-gao avatar Mar 04 '21 07:03 phenix-gao

Sorry, we did not do tests for this drive with Sprintboot+Mybatis. Currently, it may exist some bugs.

sundy-li avatar Mar 05 '21 06:03 sundy-li

Sorry, we did not do tests for this drive with Sprintboot+Mybatis. Currently, it may exist some bugs.

Fisrt, i dont use Sprintboot+Mybatis, when i use jdbc Statement.execute(Insert_sql), face the same SQLException =-=

Guanpx avatar Oct 15 '21 02:10 Guanpx

release v2.6.0 fix this ???

Guanpx avatar Nov 12 '21 02:11 Guanpx

Fisrt, i dont use Sprintboot+Mybatis, when i use jdbc Statement.execute(Insert_sql), face the same SQLException =-=

This is because you are sharing connection in multi thread, the connection is not thread safe.

sundy-li avatar Nov 12 '21 03:11 sundy-li

这个以后会支持 Sprintboot+Mybatis?

heroSoft205 avatar Jan 05 '22 09:01 heroSoft205

Will this support sprintboot + mybatis in the future?

heroSoft205 avatar Jan 05 '22 09:01 heroSoft205

Maybe it was a SQL syntax error, not a bug

yishanchuan avatar Feb 14 '22 07:02 yishanchuan