V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Geekerstar
V2EX  ›  Elasticsearch

canal 全量同步大量数据到 ES 有丢失的情况

  •  
  •   Geekerstar · 2021-11-17 13:12:32 +08:00 · 1898 次点击
    这是一个创建于 884 天前的主题,其中的信息可能已经有所发展或是发生改变。

    主表有 430 万数据,关联表有 220 万数据,是多对一的关系,理论上同步后会有 430 万数据。 用的 canal adapter 同步到 ES 。

    实际上: 数据全量导入完成, 一共导入 4134977 条数据, 耗时: 7995600

    过程中有报错如下:

    2021-11-17 02:11:21.710 [pool-3-thread-4] ERROR com.alibaba.otter.canal.client.adapter.support.Util - sqlRs has error, sql: 这里是我的 SQL LIMIT 4240000,10000 2021-11-17 02:11:21.711 [pool-3-thread-4] ERROR c.a.otter.canal.client.adapter.es7x.etl.ESEtlService - com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 60000, active 3, maxActive 3, creating 0 java.lang.RuntimeException: com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 60000, active 3, maxActive 3, creating 0 at com.alibaba.otter.canal.client.adapter.support.Util.sqlRS(Util.java:65) ~[client-adapter.common-1.1.5.jar:na] at com.alibaba.otter.canal.client.adapter.es7x.etl.ESEtlService.executeSqlImport(ESEtlService.java:64) ~[na:na] at com.alibaba.otter.canal.client.adapter.support.AbstractEtlService.lambda$importData$1(AbstractEtlService.java:91) [client-adapter.common-1.1.5.jar:na] at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_221] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_221] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_221] at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_221] Caused by: com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 60000, active 3, maxActive 3, creating 0 at com.alibaba.druid.pool.DruidDataSource.getConnectionInternal(DruidDataSource.java:1749) ~[druid-1.2.6.jar:1.2.6] at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:1419) ~[druid-1.2.6.jar:1.2.6] at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1399) ~[druid-1.2.6.jar:1.2.6] at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1389) ~[druid-1.2.6.jar:1.2.6] at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:100) ~[druid-1.2.6.jar:1.2.6] at com.alibaba.otter.canal.client.adapter.support.Util.sqlRS(Util.java:50) ~[client-adapter.common-1.1.5.jar:na] ... 6 common frames omitted

    全量同步的过程中有数据的更新及插入操作。有没有办法解决这个问题呢?

    6 条回复    2021-11-19 18:14:47 +08:00
    Saxton
        1
    Saxton  
       2021-11-18 11:50:30 +08:00
    注意看报错:GetConnectionTimeoutException: wait millis 60000, active 3, maxActive 3
    maxActive 才给 3 ? 这个值给大点
    Saxton
        2
    Saxton  
       2021-11-18 11:51:55 +08:00
    导入的数据缺失是因为导入时去连接池取连接时等待时间超过了最大超时值,直接报异常了,你这数据量就给 3 个连接肯定是不够的
    Saxton
        3
    Saxton  
       2021-11-18 11:52:56 +08:00   ❤️ 1
    另外补充下,我看你之前评论过我那个帖子,后面我放弃了 adapter ,他的代码质量真的太差了,还不如手撸一个 client 来的快
    Geekerstar
        4
    Geekerstar  
    OP
       2021-11-18 22:17:20 +08:00
    @Saxton 感谢大佬回复,active 3 只能通过改源码来解决么?我现在的做法用程序填充 etlCondition 的条件进行过滤来同步的,但是批次数据量大的时候还是会报错。。
    Saxton
        5
    Saxton  
       2021-11-19 11:23:49 +08:00
    @Geekerstar active 这个值在 application.properties 里配置的
    Geekerstar
        6
    Geekerstar  
    OP
       2021-11-19 18:14:47 +08:00
    @Saxton 没看到这个文件呢?只有 applicatio.yml ,并且里面没有 active ,在代码里的 DatasourceConfig 里面有个写死的 3
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   951 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 20:10 · PVG 04:10 · LAX 13:10 · JFK 16:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.