Race condition while registering nodes
@jacob-netguardians đang làm issue này rồi.
Từ ngày 6/12/2024.
- #2978 của @jacob-netguardians — đang mở
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- java
- Lĩnh vực
- distributed-systems
Hướng nghiên cứu
Đọc ZKHelixAdmin.addInstance() và lời gọi InstanceUtil.findInstancesWithMatchingLogicalId() được mô tả trong stack trace. Theo dõi cách hệ thống tạo hệ phân cấp INSTANCE, sau đó xác minh rằng việc đăng ký đồng thời không thể quan sát một hệ phân cấp được tạo dở dang và rằng một node được đăng ký hoàn toàn hoặc không được đăng ký chút nào.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
When two nodes are registered very closely to eachother, it can happen that the ZKHelixAdmin.addInstance() method is called at about the same time on the two nodes. The one that comes slightly before the other one will start creating ZNodes for the "INSTANCE" hierarchy in Zookeeper.
Let's say the second node starts the run of the ZKHelixAdmin.addInstance() method now. Its call to findInstancesWithMatchingLogicalId() will fail badly, throwing an exception (see below), because the first node's INSTANCE hierarchy is not complete:
[o.a.h.m.z.ZKHelixAdmin#202] Add instance node-2 to cluster ecwbq5PO.
[o.a.h.m.z.ZKUtil#163] Invalid instance setup, missing znode path: /ecwbq5PO/INSTANCES/node-1/MESSAGES
[o.a.h.m.z.ZKUtil#163] Invalid instance setup, missing znode path: /ecwbq5PO/INSTANCES/node-1/CURRENTSTATES
[o.a.h.m.z.ZKUtil#163] Invalid instance setup, missing znode path: /ecwbq5PO/INSTANCES/node-1/STATUSUPDATES
[o.a.h.m.z.ZKUtil#163] Invalid instance setup, missing znode path: /ecwbq5PO/INSTANCES/node-1/ERRORS
[o.a.h.m.z.ZKHelixAdmin#232] Failed to add instance node-2 to cluster ecwbq5PO with instance operation ENABLE. Setting INSTANCE_OPERATION to UNKNOWN instead.
org.apache.helix.HelixException: fail to get config. instance: node-1 is NOT setup in cluster: ecwbq5PO
at org.apache.helix.ConfigAccessor.getInstanceConfig(ConfigAccessor.java:908) ~[helix-core-1.4.1.1.jar:1.4.1.1]
at org.apache.helix.util.InstanceUtil.lambda$findInstancesWithMatchingLogicalId$7(InstanceUtil.java:143) ~[helix-core-1.4.1.1.jar:1.4.1.1]
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[?:?]
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) ~[?:?]
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?]
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) ~[?:?]
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) ~[?:?]
at org.apache.helix.util.InstanceUtil.findInstancesWithMatchingLogicalId(InstanceUtil.java:148) ~[helix-core-1.4.1.1.jar:1.4.1.1]
at org.apache.helix.util.InstanceUtil.validateInstanceOperationTransition(InstanceUtil.java:118) ~[helix-core-1.4.1.1.jar:1.4.1.1]
at org.apache.helix.manager.zk.ZKHelixAdmin.addInstance(ZKHelixAdmin.java:228) ~[helix-core-1.4.1.1.jar:1.4.1.1]
...
So... while adding node-2, it complains about node-1 being invalid, and consequently sets the "instance-operation" on node-2 to UNKNOWN instead of ENABLE.
Version of helix (1.4.1.1) above is due to the fact that I had already fixed #2963 and had a local version number change for this. Line numbers in the logs above may also not exactly match what is known in version 1.4.1, due to the addition of debug logging I had to do before actually understanding the problem.
Expected behavior
A node should be registered completely or not at all, not having that kind of impact on the fellow nodes' registration.
Additional context
I propose the following fix, in the ZKHelixAdmin class, creating all those nodes in the node's INSTANCE hierarchy in an atomic fashion:
Replace, in the ZKHelixAdmin class, addInstance() method, this:
_zkClient.createPersistent(PropertyPathBuilder.instanceMessage(clusterName, nodeId), true);
_zkClient.createPersistent(PropertyPathBuilder.instanceCurrentState(clusterName, nodeId), true);
_zkClient
.createPersistent(PropertyPathBuilder.instanceTaskCurrentState(clusterName, nodeId), true);
_zkClient.createPersistent(PropertyPathBuilder.instanceCustomizedState(clusterName, nodeId), true);
_zkClient.createPersistent(PropertyPathBuilder.instanceError(clusterName, nodeId), true);
_zkClient.createPersistent(PropertyPathBuilder.instanceStatusUpdate(clusterName, nodeId), true);
_zkClient.createPersistent(PropertyPathBuilder.instanceHistory(clusterName, nodeId), true);
with
// if those nodes are not created atomically, then having two nodes registering almost exactly
// at the same time could be problematic, because one node would not able to check for already
// existing instance with matching logical ID (see
// InstanceUtil.findInstancesWithMatchingLogicalId call above, where finding an incomplete
// "INSTANCE" node is a killer)
final List<Op> ops = Arrays.asList(
createPersistentNodeOp(PropertyPathBuilder.instance(clusterName, nodeId)),
createPersistentNodeOp(PropertyPathBuilder.instanceMessage(clusterName, nodeId)),
createPersistentNodeOp(PropertyPathBuilder.instanceCurrentState(clusterName, nodeId)),
createPersistentNodeOp(PropertyPathBuilder.instanceTaskCurrentState(clusterName, nodeId)),
createPersistentNodeOp(PropertyPathBuilder.instanceCustomizedState(clusterName, nodeId)),
createPersistentNodeOp(PropertyPathBuilder.instanceError(clusterName, nodeId)),
createPersistentNodeOp(PropertyPathBuilder.instanceStatusUpdate(clusterName, nodeId)),
createPersistentNodeOp(PropertyPathBuilder.instanceHistory(clusterName, nodeId))
);
_zkClient.multi(ops);
where createPersistentNodeOp method is defined as:
private static Op createPersistentNodeOp(String path) {
return Op.create(path, null, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
}
- Ngôn ngữ chính
- Java
- Star
- 505
- Fork
- 258
- Merge trung bình
- 4 ngày 20 giờ
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/helix
-
Four TestConstraintBasedAlgorithm tests pass when nothing is thrownCó thể đã có người làm @sharanggupta đã nhận hôm nay. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
-
Helix ZkClient times out after successful ZooKeeper SASL DIGEST-MD5 authenticationCó thể đã có người làm @adityaanikam đã nhận 43 ngày trước. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
-
NPE in canCompleteSwap if path doesn't existsCó thể đã có người làm @waterWang đã nhận 106 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 50/100
-
Legacy IZkStateListenerI0ItecImpl causes zombie participants by discarding session IDsCó thể đã có người làm @LZD-PratyushBhatt đã nhận 457 ngày trước. Đang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Issue tương tự
-
bug documentation good first issue help wanted priority low size XS
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
martin-francois/symphony-trello#1351 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add test coverage for ConvertUtil.parseDate() with NULL inputCó thể đã có người làm @mirajul-mollah7 đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
eclipse-sw360/sw360#4792 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
aws/aws-emulator#30 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 4 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100