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

zookeeper分配workerId多节点同时启动时存在并发安全问题 #27

Open
huminpet opened this issue Mar 25, 2024 · 0 comments
Open

Comments

@huminpet
Copy link

huminpet commented Mar 25, 2024

问题描述
zookeeper分配workerId多节点同时启动时存在并发安全问题,存在多个节点分配同一个workerId的bug

问题出现步骤
参考如下示例:

  1. 最新版本
  2. DefaultWorkerIdAllocator findNode方法
  3. if (zkClient.nodeExist(workerNodePathTem)) {
    if (addSessionNode(workerNodePathTem)) {
    savePath(index);
    return true;
    }
    }
    此代码块存在并发问题,多个节点启动时会存在分配相同workerId的情况,导致不同节点生成id重复

期望结果
每个节点分配的机器位不相同

实际结果
image
image
我这边生产环境中碰到两个节点被分配了相同机器位,一个节点index为31创建session node成功,另外一个节点index也为31进来,删除了节点后,重新创建

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