开发者社区> 问答> 正文

canal-adapter运行一段时间后就报错

运行一段时候后就报如下错误,重启就好了,过段时间又报错,一直这样,有时候几十分钟有时几个小时或者几天 开始用1.1.4,后来换了1.1.5还是一样

2021-03-08 14:16:06.400 [pool-4-thread-1] ERROR c.a.otter.canal.adapter.launcher.loader.AdapterProcessor - java.lang.NullPointerException java.lang.RuntimeException: java.lang.NullPointerException at com.alibaba.otter.canal.client.adapter.es.core.service.ESSyncService.sync(ESSyncService.java:116) ~[na:na] at com.alibaba.otter.canal.client.adapter.es.core.service.ESSyncService.sync(ESSyncService.java:64) ~[na:na] at com.alibaba.otter.canal.client.adapter.es.core.ESAdapter.sync(ESAdapter.java:115) ~[na:na] at com.alibaba.otter.canal.client.adapter.es.core.ESAdapter.sync(ESAdapter.java:94) ~[na:na] at com.alibaba.otter.canal.adapter.launcher.loader.AdapterProcessor.batchSync(AdapterProcessor.java:139) ~[client-adapter.launcher-1.1.5-SNAPSHOT.jar:na] at com.alibaba.otter.canal.adapter.launcher.loader.AdapterProcessor.lambda$null$1(AdapterProcessor.java:97) ~[client-adapter.launcher-1.1.5-SNAPSHOT.jar:na] at java.util.concurrent.CopyOnWriteArrayList.forEach(CopyOnWriteArrayList.java:891) ~[na:1.8.0_181] at com.alibaba.otter.canal.adapter.launcher.loader.AdapterProcessor.lambda$null$2(AdapterProcessor.java:94) ~[client-adapter.launcher-1.1.5-SNAPSHOT.jar:na] at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_181] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_181] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_181] at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_181] Caused by: java.lang.NullPointerException: null at org.elasticsearch.action.bulk.BulkRequest.validate(BulkRequest.java:376) ~[na:na] at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1420) ~[na:na] at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1394) ~[na:na] at org.elasticsearch.client.RestHighLevelClient.bulk(RestHighLevelClient.java:492) ~[na:na] at com.alibaba.otter.canal.client.adapter.es7x.support.ESConnection$ES7xBulkRequest.bulk(ESConnection.java:426) ~[na:na] at com.alibaba.otter.canal.client.adapter.es7x.support.ES7xTemplate.commit(ES7xTemplate.java:173) ~[na:na] at com.alibaba.otter.canal.client.adapter.es7x.support.ES7xTemplate.commitBulk(ES7xTemplate.java:343) ~[na:na] at com.alibaba.otter.canal.client.adapter.es7x.support.ES7xTemplate.update(ES7xTemplate.java:107) ~[na:na] at com.alibaba.otter.canal.client.adapter.es.core.service.ESSyncService.singleTableSimpleFiledUpdate(ESSyncService.java:827) ~[na:na] at com.alibaba.otter.canal.client.adapter.es.core.service.ESSyncService.update(ESSyncService.java:266) ~[na:na] at com.alibaba.otter.canal.client.adapter.es.core.service.ESSyncService.sync(ESSyncService.java:101) ~[na:na] ... 11 common frames omitted

原提问者GitHub用户andery119

展开
收起
山海行 2023-04-27 18:45:40 256 0
1 条回答
写回答
取消 提交回答
  • 两个解决方案:

    1、你用https://github.com/alibaba/canal/pull/3923里面的代码打个包 替换你自己的版本

    2、你可以给你的每个adapter都配置上key,application.yml和具体的adapter-config.yml 对应上

    1、application.yml在配置adapter时指定key,如:

    canalAdapters: - instance: posting_post # canal instance Name or mq topic name groups: - groupId: canal-adapter-be outerAdapters: - name: es7 key: uniq-key-1 hosts: xxx:9200 # 127.0.0.1:9200 for rest mode properties: mode: rest security.auth: elastic:pass # only used for rest mode cluster.name: elasticsearch

    2、对应的posting_post.yml配置里也指定相同key,如:

    key:uniq-key-1 dataSourceKey: postDS destination: posting_post groupId: canal-adapter-be esMapping: _index: index_post _id: id sql: "select xxx from post" etlCondition: "where upd_tm>={}" commitBatch: 3000

    这样在canal-adapter启动时每个配置在application.yml里的canalAdapter就会各自加载属于自己的OuterAdapter实例 而不会共享同一个OuterAdapter实例,导致多线程问题

    原回答者GitHub用户zhuchao941

    2023-04-28 13:39:36
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载