Skip to content

Issues with OntSynHandler #235

@giovannirco

Description

@giovannirco

We are running two different versions of OntSynHandler and Explorer in three environments and all of them failed around the block 863790.
Dev is running this commit which is tagged as v2.1.1
Stage and prod are running this commit
I couldn't pinpoint the root cause, all envs have different resources and yet it got the same error

I see some errors on stdout of OntSynHandler mentioning a duplicated entry:

[ ERROR] [2020-06-30 19:09:11] com.github.ontio.thread.BlockHandlerThread [119] - Exception occured,Synchronization thread can't work,error ...
org.springframework.dao.DuplicateKeyException:
### Error updating database.  Cause: java.sql.SQLIntegrityConstraintViolationException: Duplicate entry '2032fbaeb983066cd85fad90e74627cbef56e95f5dd142aae259053a52375d03' for key 'idx_tx_hash_index'
### The error may exist in class path resource [mapper/TxDetailMapper.xml]
### The error may involve com.github.ontio.mapper.TxDetailMapper.batchInsert-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO tbl_tx_detail (  `tx_hash`,  `tx_type`,  `tx_time`,  `block_height`,  `amount`,  `fee`,  `asset_name`,  `from_address`,  `to_address`,  `desc
ription`,  `block_index`,  `tx_index`,  `confirm_flag`,  `event_type`,  `contract_hash`,  `payer`,  `called_contract_hash`     )     VALUES            (       ?,
      ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?     )      ,      (
       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,...........

This is a very long SQL query

### Cause: java.sql.SQLIntegrityConstraintViolationException: Duplicate entry '2032fbaeb983066cd85fad90e74627cbef56e95f5dd142aae259053a52375d03' for key 'idx_tx_hash_index'
; Duplicate entry '2032fbaeb983066cd85fad90e74627cbef56e95f5dd142aae259053a52375d03' for key 'idx_tx_hash_index'; nested exception is java.sql.SQLIntegrityConstraintViolationException: Duplicate entry '2032fbaeb983066cd85fad90e74627cbef56e95f5dd142aae259053a52375d03' for key 'idx_tx_hash_index'
        at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:242)
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
        at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
        at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
        at com.sun.proxy.$Proxy92.insert(Unknown Source)
        at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:278)
        at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62)
        at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58)
        at com.sun.proxy.$Proxy98.batchInsert(Unknown Source)
        at com.github.ontio.service.CommonService.batchInsertDb(CommonService.java:104)
        at com.github.ontio.service.CommonService$$FastClassBySpringCGLIB$$b8fbd360.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 org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
        at com.github.ontio.service.CommonService$$EnhancerBySpringCGLIB$$e2058e33.batchInsertDb(<generated>)
        at com.github.ontio.thread.BlockHandlerThread.batchHandleBlockAndInsertDb(BlockHandlerThread.java:155)
        at com.github.ontio.thread.BlockHandlerThread.run(BlockHandlerThread.java:110)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        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)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.sql.SQLIntegrityConstraintViolationException: Duplicate entry '2032fbaeb983066cd85fad90e74627cbef56e95f5dd142aae259053a52375d03' for key 'idx_tx_hash_index'
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:117)
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
        at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
        at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:970)
        at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:387)
        at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3409)
        at com.alibaba.druid.wall.WallFilter.preparedStatement_execute(WallFilter.java:619)
        at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3407)
        at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:440)
        at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3407)
        at com.alibaba.druid.filter.FilterAdapter.preparedStatement_execute(FilterAdapter.java:1080)
        at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3407)
        at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.execute(PreparedStatementProxyImpl.java:167)
        at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:498)
        at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:47)
        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 org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184)
        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:498)
        at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
        ... 22 common frames omitted

Can you please help?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions