kaisun2000 commented on a change in pull request #1295:
URL: https://github.com/apache/helix/pull/1295#discussion_r483319148



##########
File path: 
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java
##########
@@ -222,22 +226,16 @@ protected ZkClient(IZkConnection zkConnection, int 
connectionTimeout, long opera
     _asyncCallRetryThread.start();
     LOG.debug("ZkClient created with _uid {}, _asyncCallRetryThread id {}", 
_uid, _asyncCallRetryThread.getId());
 
-    connect(connectionTimeout, this);
-
-    // initiate monitor
-    try {
-      if (monitorKey != null && !monitorKey.isEmpty() && monitorType != null 
&& !monitorType
-          .isEmpty()) {
-        _monitor =
-            new ZkClientMonitor(monitorType, monitorKey, monitorInstanceName, 
monitorRootPathOnly,
-                _eventThread);
-        _monitor.register();
-      } else {
-        LOG.info("ZkClient monitor key or type is not provided. Skip 
monitoring.");
-      }
-    } catch (JMException e) {
-      LOG.error("Error in creating ZkClientMonitor", e);
+    if (monitorKey != null && !monitorKey.isEmpty() && monitorType != null && 
!monitorType
+        .isEmpty()) {
+      _monitor =
+          new ZkClientMonitor(monitorType, monitorKey, monitorInstanceName, 
monitorRootPathOnly,
+              _eventThread);

Review comment:
       Maybe I mis-understand what do you mean. Can you draw the code a little 
bit more specific? 
   
   from the above pseduo code
   
   ```
   _monitor = new ZkClientMonitor();
   // Comment that we need to update the _monitor in the event lock to avoid 
missing any records about event thread.
   connect(connectTimeout, this, _monitor);
   _monitor.register()
   ```
   
   construction of ZkMonitor and ZkThreadMonitor and their registration must be 
done before the first doAsyncSync() is sent out, or you have race condition of 
missing some read/write.
   
   In the above pseudo code, `_monitor.register()` is too late, the first 
sycn() is already out and complete earlier than this register().  This violate 
the above assertion. 
   
   I may not fully understand your idea. Let us be more specific. As long as it 
works, I can change it to that way.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to