开发者社区> 问答> 正文

canal-adapter 1.1.5 增量同步ES时,出现空异常

canal-adapter 1.1.5 增量同步ES时,出现空异常。

调用全量同步操作 http://127.0.0.1:8081/etl/es7/cocs.yml,结果返回正常,Elasticsearch上也可以看到数据。 在增量同步时,出现了空异常

增量更新时,同步到ES时,报的错

2020-08-27 18:55:36.392 [pool-2-thread-1] ERROR c.a.o.canal.client.adapter.es.core.service.ESSyncService - sync error, es index: csydemo, DML : Dml{destination='example', database='ofpanda', table='companyofchina', type='UPDATE', es=1598525735000, ts=1598525736389, sql='', data=[{Id=1031, Name_zhcn=cccc, Address_zhcn=阿巴嘎旗别力古台镇乌冉克西街沃晓辉个体商住楼303号三楼, Name_en=null, State=存续, Typecode=A1151, IndustryCategory_Id=F5161, AreaCode=152522100001, OrgNo=098932702, GSNo=152522000004743, Province=内蒙古, City=锡林郭勒盟, District=阿巴嘎旗, Town=别力古台镇, VillageBuilding=别力古台社区居委会, FoundDate=2014-05-12, ApprovalDate=2014-05-12, Capital=200万人民币元, LegalPerson=赵士云, GSNoFrom= 阿巴嘎旗工商行政管理局, OrgNoFrom=内蒙古自治区锡林郭勒盟阿巴嘎旗质量技术监督局, BusinessScope=许可经营项目:无 一般经营项目:煤炭、铁精粉、铁矿石、五金建材销售。(依法须经批准的项目,经相关部门批准后方可开展经营活动。)(依法须经批准的项 目,经相关部门批准后方可开展经营活动)〓, TaxNo=, TaxNoFrom=, NameBrand=鑫骏升财, UpdateTime=2017-03-03 18:42:15.0, Lng=114.958671, Lat=44.028968, CapitalNumber=200.0, Currency=人民币, NamePinyin=ABaGaQiXinJunShengCaiMeiTanXiaoShouYouXianGongSi, NameInitial=ABGQXJSCMTXSYXGS, NameBrandPinyin=XinJunShengCai, TransferJson=null, AptitudeJson={"A_1288":1}, CustomsNo=null, CancelDate=0999-12-27, Taxpayer=null, CreditRating=null, CreditYear=null, TaxPayerState=null, UniCreditcode=null, Phone=null, Email=null, Mobile=null, Branch_GSDataFromTable=HyperLinkId1317, Rank=21, Asset=null, Liability=null, Revenue=null, Income=null, Earnings=null, Profit=null, Taxes=null, Equity=null, Employees=51, FinaceYear=null, FncValid=null, Bank=null, BankAccount=null}], old=[{Employees=50}]} 2020-08-27 18:55:36.392 [pool-2-thread-1] ERROR c.a.o.canal.client.adapter.es.core.service.ESSyncService - sync error, es index: csydemo, DML : Dml{destination='example', database='ofpanda', table='companyofchina', type='UPDATE', es=1598525735000, ts=1598525736389, sql='', data=[{Id=1031, Name_zhcn=cccc, Address_zhcn=阿巴嘎旗别力古台镇乌冉克西街沃晓辉个体商住楼303号三楼, Name_en=null, State=存续, Typecode=A1151, IndustryCategory_Id=F5161, AreaCode=152522100001, OrgNo=098932702, GSNo=152522000004743, Province=内蒙古, City=锡林郭勒盟, District=阿巴嘎旗, Town=别力古台镇, VillageBuilding=别力古台社区居委会, FoundDate=2014-05-12, ApprovalDate=2014-05-12, Capital=200万人民币元, LegalPerson=赵士云, GSNoFrom= 阿巴嘎旗工商行政管理局, OrgNoFrom=内蒙古自治区锡林郭勒盟阿巴嘎旗质量技术监督局, BusinessScope=许可经营项目:无 一般经营项目:煤炭、铁精粉、铁矿石、五金建材销售。(依法须经批准的项目,经相关部门批准后方可开展经营活动。)(依法须经批准的项 目,经相关部门批准后方可开展经营活动)〓, TaxNo=, TaxNoFrom=, NameBrand=鑫骏升财, UpdateTime=2017-03-03 18:42:15.0, Lng=114.958671, Lat=44.028968, CapitalNumber=200.0, Currency=人民币, NamePinyin=ABaGaQiXinJunShengCaiMeiTanXiaoShouYouXianGongSi, NameInitial=ABGQXJSCMTXSYXGS, NameBrandPinyin=XinJunShengCai, TransferJson=null, AptitudeJson={"A_1288":1}, CustomsNo=null, CancelDate=0999-12-27, Taxpayer=null, CreditRating=null, CreditYear=null, TaxPayerState=null, UniCreditcode=null, Phone=null, Email=null, Mobile=null, Branch_GSDataFromTable=HyperLinkId1317, Rank=21, Asset=null, Liability=null, Revenue=null, Income=null, Earnings=null, Profit=null, Taxes=null, Equity=null, Employees=51, FinaceYear=null, FncValid=null, Bank=null, BankAccount=null}], old=[{Employees=50}]} 2020-08-27 18:55:36.393 [pool-2-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(Unknown Source) ~[na:1.8.0_261] 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(Unknown Source) ~[na:1.8.0_261] at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[na:1.8.0_261] at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[na:1.8.0_261] at java.lang.Thread.run(Unknown Source) ~[na:1.8.0_261] Caused by: java.lang.NullPointerException: null at com.alibaba.otter.canal.client.adapter.es7x.support.ES7xTemplate.append4Update(ES7xTemplate.java:359) ~[na:na] at com.alibaba.otter.canal.client.adapter.es7x.support.ES7xTemplate.update(ES7xTemplate.java:106) ~[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:212) ~[na:na] at com.alibaba.otter.canal.client.adapter.es.core.service.ESSyncService.sync(ESSyncService.java:101) ~[na:na] ... 11 common frames omitted 2020-08-27 18:55:36.394 [Thread-4] ERROR c.a.otter.canal.adapter.launcher.loader.AdapterProcessor - Outer adapter sync failed! Error sync but ACK!

全量更新时,结果正常

2020-08-27 19:05:27.443 [http-nio-8081-exec-1] INFO o.a.catalina.core.ContainerBase.[Tomcat].[localhost].[/] - Initializing Spring FrameworkServlet 'dispatcherServlet' 2020-08-27 19:05:27.444 [http-nio-8081-exec-1] INFO org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'dispatcherServlet': initialization started 2020-08-27 19:05:27.463 [http-nio-8081-exec-1] INFO org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'dispatcherServlet': initialization completed in 17 ms 2020-08-27 19:05:27.499 [http-nio-8081-exec-1] INFO c.a.otter.canal.client.adapter.es7x.etl.ESEtlService - start etl to import data to index: csydemo 2020-08-27 19:05:27.630 [http-nio-8081-exec-1] INFO c.a.otter.canal.client.adapter.es7x.etl.ESEtlService - 数据全量导入完成, 一共导入 1 条数据, 耗时: 130

canal-adapter,application.yml 内容

server: port: 8081 logging: level: com.alibaba.otter.canal.client.adapter.es: DEBUG spring: jackson: date-format: yyyy-MM-dd HH:mm:ss time-zone: GMT+8 default-property-inclusion: non_null

canal.conf: mode: tcp #tcp kafka rocketMQ rabbitMQ flatMessage: true zookeeperHosts: syncBatchSize: 1000 retries: 0 timeout: accessKey: secretKey: consumerProperties: # canal tcp consumer canal.tcp.server.host: 127.0.0.1:11111 canal.tcp.zookeeper.hosts: canal.tcp.batch.size: 500 canal.tcp.username: canal.tcp.password: # kafka consumer kafka.bootstrap.servers: 127.0.0.1:9092 kafka.enable.auto.commit: false kafka.auto.commit.interval.ms: 1000 kafka.auto.offset.reset: latest kafka.request.timeout.ms: 40000 kafka.session.timeout.ms: 30000 kafka.isolation.level: read_committed kafka.max.poll.records: 1000 # rocketMQ consumer rocketmq.namespace: rocketmq.namesrv.addr: 127.0.0.1:9876 rocketmq.batch.size: 1000 rocketmq.enable.message.trace: false rocketmq.customized.trace.topic: rocketmq.access.channel: rocketmq.subscribe.filter: # rabbitMQ consumer rabbitmq.host: rabbitmq.virtual.host: rabbitmq.username: rabbitmq.password: rabbitmq.resource.ownerId:

srcDataSources: defaultDS: url: jdbc:mysql://172.16.8.16:3306/ofpanda?useUnicode=true username: root password: csy123456 canalAdapters: - instance: example # canal instance Name or mq topic name groups: - groupId: g1 outerAdapters: - name: logger - name: es7 hosts: 172.16.18.16:9200 # 127.0.0.1:9200 for rest mode properties: mode: rest # or rest cluster.name: op-es-dev-app security.auth: test:123456 # only used for rest mode

- name: kudu

key: kudu

properties:

kudu.master.address: 127.0.0.1 # ',' split multi address

canal-adapter,es7/cocs.yml 内容

dataSourceKey: defaultDS destination: example groupId: g1 esMapping: _index: csydemo _type: _doc # es 的doc名称 _id: _id sql: "select t.aa as _id, t.bb as cocName from ofpanda.table t" etlCondition: "where t.Id>={}" commitBatch: 3000

原提问者GitHub用户polei

展开
收起
山海行 2023-04-27 20:17:08 294 0
1 条回答
写回答
取消 提交回答
  • 也就是说配置_id 时 字段大小写必须一致,而且数据不能为空,如果取不到或者id是null,那么就会报空指针错误

    原回答者GitHub用户nielizixiu

    2023-04-28 14:43:21
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

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