Skip to content

通过索引别名获取mapping,mappings.get(index).get(type)报空指针异常 #4121

@xyz487

Description

@xyz487
  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ of this repository and believe that this is not a duplicate.

environment

  • canal 1.1.4
  • elasticsearch 6.3.2

Issue Description

索引使用Roller api按日期滚动分表,es目录配置文件如下:
dataSourceKey: defaultDS

outerAdapterKey: defaultDS

destination: CANAL_ORDER_POS_TOPIC
groupId: g1
esMapping:
_index: order_pos
_type: _doc
_id: _id
其中order_pos为别名,指向order_pos_2022.03-000011索引。

Steps to reproduce

  1. 重启canal-es服务
  2. 下单触发同步数据到es
  3. adapter.log 报空指针异常

If there is an exception, please attach the exception trace:

2022-03-28 10:57:12.004 [pool-3-thread-1] ERROR com.alibaba.otter.canal.client.adapter.support.Util - sqlRs has error, sql: SELECT t.id AS _id, t.id AS id, t.so_no AS soNo, t.so_sn AS soSn, t.so_type AS soType, t.order_id AS orderId, t.order_code AS orderCode, t.order_code_third AS orderCodeThird, t.order_channel AS orderChannel, t.app_type AS appType, t.mini_prog_type AS miniProgType, t.order_type AS orderType, t.take_type AS takeType, t.order_status AS orderStatus, t.from_type AS fromType, t.pay_type AS payType, date_format(t.order_time,'%Y-%m-%d %H:%i:%S') AS orderTime, date_format(t.pay_time,'%Y-%m-%d %H:%i:%S') AS payTime, t.cancel_type AS cancelType, t.delivery_type AS deliveryType, t.pos_no AS posNo, t.shop_id AS shopId, t.shop_region AS shopRegion, t.shop_code AS shopCode, t.shop_name AS shopName, t.merchant_code AS merchantCode, t.customer_id AS customerId, t.nickname AS nickname, t.mobile_phone AS mobilePhone, t.product_count AS productCount, t.origin_price AS originPrice, t.price AS price, t.is_refund AS isRefund, t.refund_status AS refundStatus, t.delivery_channel AS deliveryChannel, date_format(t.so_create_time,'%Y-%m-%d %H:%i:%S') AS soCreateTime, date_format(t.so_update_time,'%Y-%m-%d %H:%i:%S') AS soUpdateTime, t.so_creater AS soCreater, t.so_modifier AS soModifier, t.ver AS ver, date_format(t.created_time,'%Y-%m-%d %H:%i:%S') AS createdTime, date_format(t.modified_time,'%Y-%m-%d %H:%i:%S') AS modifiedTime FROM so_37 t WHERE  t.id='12LrDAPMKNy13wEzR8FbkU'   
2022-03-28 10:57:12.005 [pool-3-thread-1] ERROR c.a.otter.canal.client.adapter.es.service.ESSyncService - sync error, es index: order_pos, DML : Dml{destination='CANAL_ORDER_POS_TOPIC', database='order_pos', table='so_37', type='UPDATE', es=1648436195000, ts=1648436195904, sql='', data=[{merchant_code
=null, app_type=null, shop_code=1000003, product_count=1, discount_price=0, order_time=2022-03-28 10:56:39.0, product_price=null, so_no=2203281056230001, cancel_type=null, marketing_type=null, consignee_address_detail=null, coupon_name=null, so_update_time=2022-03-28 10:56:56.0, refund_audit_status=null, refund_remark=null, order_status=80, point_ded=null, delivery_fee=null, merchant_price=null, so_modifier=1481822769141383170, coupon_id=null, take_no=2301, so_sn=1, delivery_type=null, price=500, gift_memo=null, refund_operator_id=null, id=12LrDAPMKNy13wEzR8FbkU, so_creater=1481822769141383170, order_type=3, cancel_time=null, tableware_count=null, consignee_address=null, created_time=2022-03-28 10:56:21.0, ver=1, refund_status=null, consignee=null, platform_bear_price=null, shop_region=411503, refund_reason_type=null, delivery_channel=null, take_type=1, shop_name=测试专用门店-改, driver_phone=null, finish_time=2022-03-28 10:56:56.0, ignore_price=0, pay_time=2022-03-28 10:56:41.0, order_code=null, shop_id=1450720756966739970, refund_time=null, marketing_name=null, merchant_bear_price=null, origin_price=500, order_id=null, coupon_discount=null, so_create_time=2022-03-28 10:56:41.0, refund_fail_type=null, pos_info_id=1493050454793953281, remark=null, refund_operator_name=null, consignee_phone=null, meal_fee=null, people_num=null, modified_time=2022-03-28 10:56:36.0, tax_no=null, mobile_phone=null, pos_sn=12LgGQt2SKcQuh7e3YghVD, nickname=null, mini_prog_type=null, pay_type=4, commission=null, refund_reason=null, invoice_type=null, is_invoice=null, take_time=2022-03-28 10:56:39.0, order_channel=3, is_refund=1, from_type=null, coupon_code=null, marketing_discount=null, driver_name=null, origin_so_id=null, refund_reject=null, order_code_third=null, so_type=1, marketing_id=null, invoice=null, pos_no=23, customer_id=null}], old=[{order_status=70, ver=0, modified_time=2022-03-28 10:56:21.0, is_refund=0, finish_time=2022-03-28 10:56:39.0, so_update_time=2022-03-28 10:56:41.0}]}
2022-03-28 10:57:12.009 [pool-3-thread-1] ERROR c.a.o.c.a.launcher.loader.CanalAdapterRocketMQWorker - java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException
        at com.alibaba.otter.canal.client.adapter.es.service.ESSyncService.sync(ESSyncService.java:110)
        at com.alibaba.otter.canal.client.adapter.es.service.ESSyncService.sync(ESSyncService.java:58)
        at com.alibaba.otter.canal.client.adapter.es.ESAdapter.sync(ESAdapter.java:169)
        at com.alibaba.otter.canal.client.adapter.es.ESAdapter.sync(ESAdapter.java:148)
        at com.alibaba.otter.canal.adapter.launcher.loader.AbstractCanalAdapterWorker.batchSync(AbstractCanalAdapterWorker.java:201)
        at com.alibaba.otter.canal.adapter.launcher.loader.AbstractCanalAdapterWorker.lambda$null$4(AbstractCanalAdapterWorker.java:106)
        at java.util.ArrayList.forEach(ArrayList.java:1259)
        at com.alibaba.otter.canal.adapter.launcher.loader.AbstractCanalAdapterWorker.lambda$null$5(AbstractCanalAdapterWorker.java:103)
        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.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException
        at com.alibaba.otter.canal.client.adapter.support.Util.sqlRS(Util.java:45)
        at com.alibaba.otter.canal.client.adapter.es.service.ESSyncService.mainTableUpdate(ESSyncService.java:825)
        at com.alibaba.otter.canal.client.adapter.es.service.ESSyncService.update(ESSyncService.java:262)
        at com.alibaba.otter.canal.client.adapter.es.service.ESSyncService.sync(ESSyncService.java:95)
        ... 11 common frames omitted
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
        at com.alibaba.otter.canal.client.adapter.es.service.ESSyncService.lambda$mainTableUpdate$7(ESSyncService.java:842)
        at com.alibaba.otter.canal.client.adapter.support.Util.sqlRS(Util.java:41)
        ... 14 common frames omitted
Caused by: java.lang.NullPointerException: null
        at com.alibaba.otter.canal.client.adapter.es.support.ESConnection.getMapping(ESConnection.java:150)
        at com.alibaba.otter.canal.client.adapter.es.support.ESTemplate.getEsType(ESTemplate.java:494)
        at com.alibaba.otter.canal.client.adapter.es.support.ESTemplate.getValFromRS(ESTemplate.java:262)
        at com.alibaba.otter.canal.client.adapter.es.support.ESTemplate.getESDataFromRS(ESTemplate.java:325)
        at com.alibaba.otter.canal.client.adapter.es.service.ESSyncService.lambda$mainTableUpdate$7(ESSyncService.java:829)
        ... 15 common frames omitted
2022-03-28 10:57:12.009 [Thread-4] ERROR c.a.o.c.a.launcher.loader.CanalAdapterRocketMQWorker - java.lang.RuntimeException: Outer adapter sync failed!  Error sync but ACK!

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