开发者社区> 问答> 正文

canal 服务端运行一段时间会报如下错。不知道如何解决。

我程序启动连接canal 报错: something goes wrong with reason: something goes wrong with channel com.alibaba.otter.canal.server.exception.CanalServerException: ack error , clientId:1001 batchId:47 is not exist , please check

怎么解决?canal服务端我也重启了。运行了一下,过一阵程序启动还是继续会报错

下面是我的代码

while (true) { Message message = connector.getWithoutAck(1000); // 获取指定数量的数据 long batchId = message.getId(); int size = message.getEntries().size(); if (batchId == -1 || size == 0) { try { Thread.sleep(1000); } catch (InterruptedException e) {} } else { long beginTime = DateUtils.nowDateToTimestamp(); //逻辑:1先判断插入与更新2如果是状态已完成4,则获取数据。进行保存,存mongdb try { switchHandle(message.getEntries()); connector.ack(batchId); // 提交确认 } catch (Exception e) { //System.out.println("同步错误,需要回滚" + e.getMessage()); logger.error("同步错误,需要回滚", e); connector.rollback(batchId); continue; } long endTime = DateUtils.nowDateToTimestamp(); logger.info("此次同步时间是:" + (endTime - beginTime) + " ms"); } }

原提问者GitHub用户fanqinghui

展开
收起
绿子直子 2023-05-09 15:47:54 92 0
1 条回答
写回答
取消 提交回答
  • 出现这个问题,怀疑是server端发生了instance重启,导致内存里的batchId丢失. 检查一下服务端的日志

    原回答者GitHub用户agapple

    2023-05-10 10:46:39
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

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