Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

从节点死循环等待分片完成 #2395

Open
ExploreHeart opened this issue May 30, 2024 · 0 comments
Open

从节点死循环等待分片完成 #2395

ExploreHeart opened this issue May 30, 2024 · 0 comments

Comments

@ExploreHeart
Copy link

while (!leaderService.isLeaderUntilBlock() && (jobNodeStorage.isJobNodeExisted(ShardingNode.NECESSARY) || jobNodeStorage.isJobNodeExisted(ShardingNode.PROCESSING))) {

当前判断条件

  1. 非主节点:!leaderService.isLeaderUntilBlock() ;
  2. 存在需要分片标识或者主节点插入正在分片标识:(jobNodeStorage.isJobNodeExisted(ShardingNode.NECESSARY) || jobNodeStorage.isJobNodeExisted(ShardingNode.PROCESSING))

触发死循环条件

  1. 主分片完成后,分片标识被重新插入(实例上线或者下线);
  2. 触发这个场景后,从节点将一直循环请求ZK到下一轮任务调度;
  3. 当前逻辑是100ms执行上述判断逻辑,对ZK请求4次,单个任务对ZK请求=40次/s;

优化思路

  1. 任务执行调度时,插入当前轮次执行时间和下一轮执行时间到上下文中;
  2. 主节点分片完成后,插入分片完成时间到leader/sharding节点
  3. 从节点等待分片完成逻辑,增加读取主节点分片完成时间判断,当(分片完成时间>当前轮次&&分片完成时间<下一轮次 )或者 分片完成时间>=下一轮次时,退出分片等待完成循环
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant