You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2020/10/27 22:37:03 UTC

[GitHub] [helix] kaisun2000 opened a new pull request #1487: Make enable error log to ZK from participant or controller configurable

kaisun2000 opened a new pull request #1487:
URL: https://github.com/apache/helix/pull/1487


   ### Issues
   
   - [ ] My PR addresses the following Helix issues and references them in the PR description:
   
       fix #1486
   
   ### Description
   
   - [x] Here are some details about my PR, including screenshots of any UI changes:
   
       Improve statusUpdateUtil log error to ZK by adding an option to enabled
       it. By default, it would not log error to ZK. This is to avoid some
       error code path that keep flooding ZK sever which cause DoS to Zk.
       Such as HelixTaskExecutor onMessage creation messageHandler exception.
   
   ### Tests
   
   - [x] The following tests are written for this issue:
     TestStatusUpdateUtil
   
   - [x] The following is the result of the "mvn test" command on the appropriate module:
   
   github running
   
   ### Documentation (Optional)
   
   - In case of new functionality, my PR adds documentation in the following wiki page:
   
   (Link the GitHub wiki you added)
   
   ### Commits
   
   - My commits all reference appropriate Apache Helix GitHub issues in their subject lines. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Code Quality
   
   - My diff has been formatted using helix-style.xml 
   (helix-style-intellij.xml if IntelliJ IDE is used)
   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on pull request #1487:
URL: https://github.com/apache/helix/pull/1487#issuecomment-718324622


   > The PR title seems not grammar correct, maybe "Add a configuration option to allow enable/disable writing error log to ZK"?
   
   changed.


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] jiajunwang commented on a change in pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
jiajunwang commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r514024167



##########
File path: helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
##########
@@ -560,6 +565,10 @@ void publishStatusUpdateRecord(ZNRecord record, Message message, Level level,
    */
   void publishErrorRecord(ZNRecord record, String instanceName, String updateSubPath,
       String updateKey, String sessionId, HelixDataAccessor accessor, boolean isController) {
+    _logger.error("StatusUpdate Error record: {}", record.toString());
+    if (!ERROR_LOG_TO_ZK_ENABLED) {

Review comment:
       IMHO,
   
   if (!ERROR_LOG_TO_ZK_ENABLED) {
     _logger.error("StatusUpdate Error record: {}", record.toString());
     return;
   }
   ...




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on a change in pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r520845455



##########
File path: helix-common/src/main/java/org/apache/helix/SystemPropertyKeys.java
##########
@@ -82,4 +82,6 @@
   // System Property Metadata Store Directory Server endpoint key
   public static final String MSDS_SERVER_ENDPOINT_KEY =
       MetadataStoreRoutingConstants.MSDS_SERVER_ENDPOINT_KEY;
+
+  public static final String STATEUPDATEUTIL_ERROR_LOG2ZK_ENABLED = "helix.StateUpdateUtil.errorLog.enabled";

Review comment:
       STATEUPDATEUTIL_ERROR_PERSISTANCY_ENABLED




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on a change in pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r520747669



##########
File path: helix-common/src/main/java/org/apache/helix/SystemPropertyKeys.java
##########
@@ -82,4 +82,6 @@
   // System Property Metadata Store Directory Server endpoint key
   public static final String MSDS_SERVER_ENDPOINT_KEY =
       MetadataStoreRoutingConstants.MSDS_SERVER_ENDPOINT_KEY;
+
+  public static final String STATEUPDATEUTIL_ERROR_LOG2ZK_ENABLED = "helix.StateUpdateUtil.errorLog.enabled";

Review comment:
       Can you illustrate the idea how to make it enum? Something like 
   
   ```
   enum STATEUPDATE_ERROR_REPORTING_CHANNEL {
       LOG4J,
       LOG2ZK
   };
   
   ```
   
   and in the system property, 
   `public static final String STATEUPDATEUTIL_ERROR_LOG2ZK_ENABLED = <enum value>`;
   then we will convert the system property to enum value?




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] pkuwm commented on a change in pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
pkuwm commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r520850428



##########
File path: helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
##########
@@ -560,6 +556,10 @@ void publishStatusUpdateRecord(ZNRecord record, Message message, Level level,
    */
   void publishErrorRecord(ZNRecord record, String instanceName, String updateSubPath,
       String updateKey, String sessionId, HelixDataAccessor accessor, boolean isController) {
+    _logger.error("StatusUpdate Error record: {}", record);

Review comment:
       Do we really need this error log for the whole record? It may eat up the disk, imagine if znrecord is close to 1 MB. I am not sure if we really need the record for troubleshooting. Maybe logging the instanceName, updateSubPath, sessionId, etc. is good enough?




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] lei-xia commented on pull request #1487: Make enable error log to ZK from participant or controller configurable

Posted by GitBox <gi...@apache.org>.
lei-xia commented on pull request #1487:
URL: https://github.com/apache/helix/pull/1487#issuecomment-718322908


   The PR title seems not grammar correct, maybe "Add a configuration option to allow enable/disable writing error log to ZK"?


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] jiajunwang commented on a change in pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
jiajunwang commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r514025343



##########
File path: helix-core/src/test/java/org/apache/helix/util/TestStatusUpdateUtil.java
##########
@@ -0,0 +1,76 @@
+package org.apache.helix.util;
+
+import org.apache.helix.HelixConstants;
+import org.apache.helix.PropertyPathBuilder;
+import org.apache.helix.SystemPropertyKeys;
+import org.apache.helix.TestHelper;
+import org.apache.helix.common.ZkTestBase;
+import org.apache.helix.integration.manager.MockParticipantManager;
+import org.apache.helix.messaging.handling.HelixStateTransitionHandler;
+import org.apache.helix.model.Message;
+import org.apache.helix.zookeeper.datamodel.ZNRecord;
+import org.apache.helix.zookeeper.zkclient.exception.ZkException;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+
+public class TestStatusUpdateUtil extends ZkTestBase {
+  private String clusterName = TestHelper.getTestClassName();
+  static {
+    System.clearProperty(SystemPropertyKeys.STATEUPDATEUTIL_ERROR_LOG_ENABLED);
+  }
+
+  @Test
+  public void testDisableErrorLogByDefault() throws Exception {
+    StatusUpdateUtil _statusUpdateUtil = new StatusUpdateUtil();
+    int n = 1;
+
+    Exception e = new RuntimeException("test exception");
+
+    TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
+        "localhost", // participant name prefix
+        "TestDB", // resource name prefix
+        1, // resources
+        1, // partitions per resource
+        n, // number of nodes
+        1, // replicas
+        "MasterSlave", true);
+
+    MockParticipantManager[] participants = new MockParticipantManager[n];
+
+    for (int i = 0; i < n; i++) {
+      String instanceName = "localhost_" + (12918 + i);
+      participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+      participants[i].syncStart();
+    }
+
+    Message message = new Message(Message.MessageType.STATE_TRANSITION, "Some unique id");
+    message.setSrcName("cm-instance-0");
+    message.setTgtSessionId(participants[0].getSessionId());
+    message.setFromState("Offline");
+    message.setToState("Slave");
+    message.setPartitionName("TestDB_0");
+    message.setMsgId("Some unique message id");
+    message.setResourceName("TestDB");
+    message.setTgtName("localhost_12918");
+    message.setStateModelDef("MasterSlave");
+    message.setStateModelFactoryName(HelixConstants.DEFAULT_STATE_MODEL_FACTORY);
+    _statusUpdateUtil.logError(message, HelixStateTransitionHandler.class, e,
+        "test status update", participants[0]);
+
+    // assert by default, not logged to Zookeeper
+    String errPath = PropertyPathBuilder.instanceError(clusterName, "localhost_12918",
+        participants[0].getSessionId(),
+        "TestDB", "TestDB_0");
+    try {
+      ZNRecord error = _gZkClient.readData(errPath);
+      Assert.fail("not expecting being able to send error logs to ZK by default.");
+    } catch (ZkException zke) {
+      Assert.assertTrue(true);
+    }
+
+    for (int i = 0; i < n; i++) {
+      participants[i].syncStop();

Review comment:
       This is a potential thread leak if test failure.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on a change in pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r516200103



##########
File path: helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
##########
@@ -560,6 +565,10 @@ void publishStatusUpdateRecord(ZNRecord record, Message message, Level level,
    */
   void publishErrorRecord(ZNRecord record, String instanceName, String updateSubPath,
       String updateKey, String sessionId, HelixDataAccessor accessor, boolean isController) {
+    _logger.error("StatusUpdate Error record: {}", record.toString());
+    if (!ERROR_LOG_TO_ZK_ENABLED) {

Review comment:
       So let us keep it this way. The reasoning is that source of truth logging is in log file.

##########
File path: helix-common/src/main/java/org/apache/helix/SystemPropertyKeys.java
##########
@@ -82,4 +82,6 @@
   // System Property Metadata Store Directory Server endpoint key
   public static final String MSDS_SERVER_ENDPOINT_KEY =
       MetadataStoreRoutingConstants.MSDS_SERVER_ENDPOINT_KEY;
+
+  public static final String STATEUPDATEUTIL_ERROR_LOG_ENABLED = "helix.StateUpdateUtil.errorLog.enabled";

Review comment:
       @lei-xia, so let us change the name to " STATEUPDATEUTIL_ERROR_LOG2ZK_ENABLED?

##########
File path: helix-common/src/main/java/org/apache/helix/SystemPropertyKeys.java
##########
@@ -82,4 +82,6 @@
   // System Property Metadata Store Directory Server endpoint key
   public static final String MSDS_SERVER_ENDPOINT_KEY =
       MetadataStoreRoutingConstants.MSDS_SERVER_ENDPOINT_KEY;
+
+  public static final String STATEUPDATEUTIL_ERROR_LOG_ENABLED = "helix.StateUpdateUtil.errorLog.enabled";

Review comment:
       @dasahcc, ZkSystemPropertyKeys is for Zookeeper related. This is more to me like logging related.

##########
File path: helix-core/src/main/java/org/apache/helix/util/HelixUtil.java
##########
@@ -62,6 +62,7 @@
 import org.apache.helix.model.ResourceAssignment;
 import org.apache.helix.model.ResourceConfig;
 import org.apache.helix.model.StateModelDefinition;
+import org.apache.helix.tools.ClusterVerifiers.StrictMatchExternalViewVerifier;

Review comment:
       removed.

##########
File path: helix-core/src/main/java/org/apache/helix/util/HelixUtil.java
##########
@@ -470,11 +471,26 @@ public static int getSystemPropertyAsInt(String propertyKey, int propertyDefault
   }
 
   /**
-   * Get the value of system property
+   * Get the boolean value of system property
    * @param propertyKey
    * @param propertyDefaultValue
    * @return
    */
+  public static boolean getSystemPropertyAsBoolean(String propertyKey, String propertyDefaultValue) {

Review comment:
       removed.

##########
File path: helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
##########
@@ -560,6 +565,10 @@ void publishStatusUpdateRecord(ZNRecord record, Message message, Level level,
    */
   void publishErrorRecord(ZNRecord record, String instanceName, String updateSubPath,
       String updateKey, String sessionId, HelixDataAccessor accessor, boolean isController) {
+    _logger.error("StatusUpdate Error record: {}", record.toString());

Review comment:
       changed.

##########
File path: helix-core/src/test/java/org/apache/helix/util/TestStatusUpdateUtil.java
##########
@@ -0,0 +1,76 @@
+package org.apache.helix.util;
+

Review comment:
       added.

##########
File path: helix-core/src/test/java/org/apache/helix/util/TestStatusUpdateUtil.java
##########
@@ -0,0 +1,76 @@
+package org.apache.helix.util;
+
+import org.apache.helix.HelixConstants;
+import org.apache.helix.PropertyPathBuilder;
+import org.apache.helix.SystemPropertyKeys;
+import org.apache.helix.TestHelper;
+import org.apache.helix.common.ZkTestBase;
+import org.apache.helix.integration.manager.MockParticipantManager;
+import org.apache.helix.messaging.handling.HelixStateTransitionHandler;
+import org.apache.helix.model.Message;
+import org.apache.helix.zookeeper.datamodel.ZNRecord;
+import org.apache.helix.zookeeper.zkclient.exception.ZkException;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+
+public class TestStatusUpdateUtil extends ZkTestBase {
+  private String clusterName = TestHelper.getTestClassName();
+  static {
+    System.clearProperty(SystemPropertyKeys.STATEUPDATEUTIL_ERROR_LOG_ENABLED);
+  }
+
+  @Test
+  public void testDisableErrorLogByDefault() throws Exception {
+    StatusUpdateUtil _statusUpdateUtil = new StatusUpdateUtil();
+    int n = 1;
+
+    Exception e = new RuntimeException("test exception");
+
+    TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
+        "localhost", // participant name prefix
+        "TestDB", // resource name prefix
+        1, // resources
+        1, // partitions per resource
+        n, // number of nodes
+        1, // replicas
+        "MasterSlave", true);
+
+    MockParticipantManager[] participants = new MockParticipantManager[n];
+
+    for (int i = 0; i < n; i++) {
+      String instanceName = "localhost_" + (12918 + i);
+      participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+      participants[i].syncStart();
+    }
+
+    Message message = new Message(Message.MessageType.STATE_TRANSITION, "Some unique id");
+    message.setSrcName("cm-instance-0");
+    message.setTgtSessionId(participants[0].getSessionId());
+    message.setFromState("Offline");
+    message.setToState("Slave");
+    message.setPartitionName("TestDB_0");
+    message.setMsgId("Some unique message id");
+    message.setResourceName("TestDB");
+    message.setTgtName("localhost_12918");
+    message.setStateModelDef("MasterSlave");
+    message.setStateModelFactoryName(HelixConstants.DEFAULT_STATE_MODEL_FACTORY);
+    _statusUpdateUtil.logError(message, HelixStateTransitionHandler.class, e,
+        "test status update", participants[0]);
+
+    // assert by default, not logged to Zookeeper
+    String errPath = PropertyPathBuilder.instanceError(clusterName, "localhost_12918",
+        participants[0].getSessionId(),
+        "TestDB", "TestDB_0");
+    try {
+      ZNRecord error = _gZkClient.readData(errPath);
+      Assert.fail("not expecting being able to send error logs to ZK by default.");
+    } catch (ZkException zke) {
+      Assert.assertTrue(true);
+    }
+
+    for (int i = 0; i < n; i++) {
+      participants[i].syncStop();

Review comment:
       fixed in tearing down in afterClass()

##########
File path: helix-core/src/test/java/org/apache/helix/integration/manager/TestParticipantManager.java
##########
@@ -66,6 +66,9 @@
 public class TestParticipantManager extends ZkTestBase {
   private MBeanServer _server = ManagementFactory.getPlatformMBeanServer();
   private String clusterName = TestHelper.getTestClassName();
+  static {
+    System.setProperty(SystemPropertyKeys.STATEUPDATEUTIL_ERROR_LOG_ENABLED, "true");

Review comment:
       ```
     public void testSessionExpiryInTransition() throws Exception {
   
       String errPath = PropertyPathBuilder.instanceError(clusterName, "localhost_12918", oldSessionId,
           "TestDB0", "TestDB0_0");
       ZNRecord error = _gZkClient.readData(errPath);
       Assert.assertNotNull(error,
           "InterruptedException should happen in old session since task is being cancelled during handleNewSession");
   
   ```
   
   To make sure the following test would work.
   

##########
File path: helix-core/src/test/java/org/apache/helix/integration/manager/TestParticipantManager.java
##########
@@ -66,6 +66,9 @@
 public class TestParticipantManager extends ZkTestBase {
   private MBeanServer _server = ManagementFactory.getPlatformMBeanServer();
   private String clusterName = TestHelper.getTestClassName();
+  static {
+    System.setProperty(SystemPropertyKeys.STATEUPDATEUTIL_ERROR_LOG_ENABLED, "true");

Review comment:
       ERROR_LOG_TO_ZK_ENABLED in StatusUpdateUtil is static. I changed to use reflection to control the value now. So there is no need to set or clear it in `TestStatusUpdateUtil` anymore.

##########
File path: helix-core/src/test/java/org/apache/helix/util/TestStatusUpdateUtil.java
##########
@@ -0,0 +1,76 @@
+package org.apache.helix.util;
+
+import org.apache.helix.HelixConstants;
+import org.apache.helix.PropertyPathBuilder;
+import org.apache.helix.SystemPropertyKeys;
+import org.apache.helix.TestHelper;
+import org.apache.helix.common.ZkTestBase;
+import org.apache.helix.integration.manager.MockParticipantManager;
+import org.apache.helix.messaging.handling.HelixStateTransitionHandler;
+import org.apache.helix.model.Message;
+import org.apache.helix.zookeeper.datamodel.ZNRecord;
+import org.apache.helix.zookeeper.zkclient.exception.ZkException;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+
+public class TestStatusUpdateUtil extends ZkTestBase {
+  private String clusterName = TestHelper.getTestClassName();
+  static {
+    System.clearProperty(SystemPropertyKeys.STATEUPDATEUTIL_ERROR_LOG_ENABLED);
+  }
+
+  @Test
+  public void testDisableErrorLogByDefault() throws Exception {

Review comment:
       both added now.

##########
File path: helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
##########
@@ -560,6 +565,10 @@ void publishStatusUpdateRecord(ZNRecord record, Message message, Level level,
    */
   void publishErrorRecord(ZNRecord record, String instanceName, String updateSubPath,
       String updateKey, String sessionId, HelixDataAccessor accessor, boolean isController) {
+    _logger.error("StatusUpdate Error record: {}", record.toString());
+    if (!ERROR_LOG_TO_ZK_ENABLED) {

Review comment:
       Good point. The log are in `publishStatusUpdateRecord' and `publishErrorRecord`.
   
   Here publishStatusUpdateRecord would never log to Zk anymore. The participant side, it has trace level log to log4j, but not controller side. Let me revise it to the way that both controller and participant side has log to log4j then.

##########
File path: helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
##########
@@ -560,6 +565,10 @@ void publishStatusUpdateRecord(ZNRecord record, Message message, Level level,
    */
   void publishErrorRecord(ZNRecord record, String instanceName, String updateSubPath,
       String updateKey, String sessionId, HelixDataAccessor accessor, boolean isController) {
+    _logger.error("StatusUpdate Error record: {}", record.toString());
+    if (!ERROR_LOG_TO_ZK_ENABLED) {

Review comment:
       Good point. The log are in `publishStatusUpdateRecord` and `publishErrorRecord`.
   
   Here publishStatusUpdateRecord would never log to Zk anymore. The participant side, it has trace level log to log4j, but not controller side. Let me revise it to the way that both controller and participant side has log to log4j then.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on a change in pull request #1487: Make enable error log to ZK from participant or controller configurable

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r513842745



##########
File path: helix-common/src/main/java/org/apache/helix/SystemPropertyKeys.java
##########
@@ -82,4 +82,6 @@
   // System Property Metadata Store Directory Server endpoint key
   public static final String MSDS_SERVER_ENDPOINT_KEY =
       MetadataStoreRoutingConstants.MSDS_SERVER_ENDPOINT_KEY;
+
+  public static final String STATEUPDATEUTIL_ERROR_LOG_ENABLED = "helix.StateUpdateUtil.errorLog.enabled";

Review comment:
       This is not minor, this is a MAJOR, a very good point. Let me make sure we have error level log out to logfile.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on a change in pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r520889149



##########
File path: helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
##########
@@ -492,47 +496,39 @@ void publishStatusUpdateRecord(ZNRecord record, Message message, Level level,
 
     Builder keyBuilder = accessor.keyBuilder();
     if (!_recordedMessages.containsKey(message.getMsgId())) {
-      if (isController) {
-        accessor
-            .updateProperty(keyBuilder.controllerTaskStatus(statusUpdateSubPath, statusUpdateKey),
-                new StatusUpdate(createMessageLogRecord(message)));
+      ZNRecord statusUpdateRecord = createMessageLogRecord(message);
+      PropertyKey propertyKey;
 
+      if (isController) {
+        propertyKey = keyBuilder.controllerTaskStatus(statusUpdateSubPath, statusUpdateKey);
+        accessor.updateProperty(propertyKey, new StatusUpdate(statusUpdateRecord));
       } else {
-
-        PropertyKey propertyKey =
+        propertyKey =
             keyBuilder.stateTransitionStatus(instanceName, sessionId, statusUpdateSubPath,
                 statusUpdateKey);
-
-        ZNRecord statusUpdateRecord = createMessageLogRecord(message);
-
-        // For now write participant StatusUpdates to log4j.
-        // we are using restlet as another data channel to report to controller.
-        if (_logger.isTraceEnabled()) {
-          _logger.trace("StatusUpdate path:" + propertyKey.getPath() + ", updates:"
-              + statusUpdateRecord);
-        }
         accessor.updateProperty(propertyKey, new StatusUpdate(statusUpdateRecord));
+      }
 
+      if (_logger.isTraceEnabled()) {
+        _logger.trace("StatusUpdate path:" + propertyKey.getPath() + ", updates:"
+            + statusUpdateRecord);
       }
       _recordedMessages.put(message.getMsgId(), message.getMsgId());
     }
 
+    PropertyKey propertyKey;
     if (isController) {
-      accessor.updateProperty(
-          keyBuilder.controllerTaskStatus(statusUpdateSubPath, statusUpdateKey), new StatusUpdate(
-              record));
+      propertyKey = keyBuilder.controllerTaskStatus(statusUpdateSubPath, statusUpdateKey);
+      accessor.updateProperty(propertyKey, new StatusUpdate(record));

Review comment:
       fixed.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on pull request #1487:
URL: https://github.com/apache/helix/pull/1487#issuecomment-725196076


   The PR is approved, please help to merge
   
   > Improve statusUpdateUtil log error to ZK by adding an option to enabled
   it. By default, it would not log error to ZK. This is to avoid some
   error code path that keep flooding ZK sever which cause DoS to Zk.
   Such as HelixTaskExecutor onMessage creation messageHandler exception.


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on a change in pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r521111524



##########
File path: helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
##########
@@ -55,6 +56,9 @@
 public class StatusUpdateUtil {
   static Logger _logger = LoggerFactory.getLogger(StatusUpdateUtil.class);
 
+  public static final boolean ERROR_LOG_TO_ZK_ENABLED =

Review comment:
       This is not the case. Just tested, it does not work. I am not an expert in this area. Feel free to let me know if you know the trick here.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] jiajunwang commented on a change in pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
jiajunwang commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r521033092



##########
File path: helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
##########
@@ -55,6 +56,9 @@
 public class StatusUpdateUtil {
   static Logger _logger = LoggerFactory.getLogger(StatusUpdateUtil.class);
 
+  public static final boolean ERROR_LOG_TO_ZK_ENABLED =

Review comment:
       nit, private?
   Since we already doing reflection, I think making it private won't block the test, right? 




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on a change in pull request #1487: Make enable error log to ZK from participant or controller configurable

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r513880560



##########
File path: helix-core/src/test/java/org/apache/helix/util/TestStatusUpdateUtil.java
##########
@@ -0,0 +1,76 @@
+package org.apache.helix.util;
+
+import org.apache.helix.HelixConstants;
+import org.apache.helix.PropertyPathBuilder;
+import org.apache.helix.SystemPropertyKeys;
+import org.apache.helix.TestHelper;
+import org.apache.helix.common.ZkTestBase;
+import org.apache.helix.integration.manager.MockParticipantManager;
+import org.apache.helix.messaging.handling.HelixStateTransitionHandler;
+import org.apache.helix.model.Message;
+import org.apache.helix.zookeeper.datamodel.ZNRecord;
+import org.apache.helix.zookeeper.zkclient.exception.ZkException;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+
+public class TestStatusUpdateUtil extends ZkTestBase {
+  private String clusterName = TestHelper.getTestClassName();
+  static {
+    System.clearProperty(SystemPropertyKeys.STATEUPDATEUTIL_ERROR_LOG_ENABLED);
+  }
+
+  @Test
+  public void testDisableErrorLogByDefault() throws Exception {

Review comment:
       It is already tested in TestParticipantManager. testSessionExpiryInTransition assert the error log znode is not null. Do we need to add another explicit one here? 




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] lei-xia commented on a change in pull request #1487: Make enable error log to ZK from participant or controller configurable

Posted by GitBox <gi...@apache.org>.
lei-xia commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r513827042



##########
File path: helix-core/src/test/java/org/apache/helix/integration/manager/TestParticipantManager.java
##########
@@ -66,6 +66,9 @@
 public class TestParticipantManager extends ZkTestBase {
   private MBeanServer _server = ManagementFactory.getPlatformMBeanServer();
   private String clusterName = TestHelper.getTestClassName();
+  static {
+    System.setProperty(SystemPropertyKeys.STATEUPDATEUTIL_ERROR_LOG_ENABLED, "enabled");

Review comment:
       Same here, use HelixUtil.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on pull request #1487:
URL: https://github.com/apache/helix/pull/1487#issuecomment-724379455


   @dasahcc , @pkuwm , @jiajunwang , ping?


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] lei-xia commented on a change in pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
lei-xia commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r514321686



##########
File path: helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
##########
@@ -560,6 +565,10 @@ void publishStatusUpdateRecord(ZNRecord record, Message message, Level level,
    */
   void publishErrorRecord(ZNRecord record, String instanceName, String updateSubPath,
       String updateKey, String sessionId, HelixDataAccessor accessor, boolean isController) {
+    _logger.error("StatusUpdate Error record: {}", record.toString());
+    if (!ERROR_LOG_TO_ZK_ENABLED) {

Review comment:
       Not actually, even we disable writting to ZK, we still need to log into local log file, right?




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] pkuwm commented on pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
pkuwm commented on pull request #1487:
URL: https://github.com/apache/helix/pull/1487#issuecomment-725206743


   I'll merge this PR once the PR CI is successful.


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on a change in pull request #1487: Make enable error log to ZK from participant or controller configurable

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r513842745



##########
File path: helix-common/src/main/java/org/apache/helix/SystemPropertyKeys.java
##########
@@ -82,4 +82,6 @@
   // System Property Metadata Store Directory Server endpoint key
   public static final String MSDS_SERVER_ENDPOINT_KEY =
       MetadataStoreRoutingConstants.MSDS_SERVER_ENDPOINT_KEY;
+
+  public static final String STATEUPDATEUTIL_ERROR_LOG_ENABLED = "helix.StateUpdateUtil.errorLog.enabled";

Review comment:
       This is not minor, this is a MAJOR, a very good point. Let me make sure we have error level log out.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] lei-xia commented on a change in pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
lei-xia commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r514327483



##########
File path: helix-core/src/test/java/org/apache/helix/util/TestStatusUpdateUtil.java
##########
@@ -0,0 +1,76 @@
+package org.apache.helix.util;
+
+import org.apache.helix.HelixConstants;
+import org.apache.helix.PropertyPathBuilder;
+import org.apache.helix.SystemPropertyKeys;
+import org.apache.helix.TestHelper;
+import org.apache.helix.common.ZkTestBase;
+import org.apache.helix.integration.manager.MockParticipantManager;
+import org.apache.helix.messaging.handling.HelixStateTransitionHandler;
+import org.apache.helix.model.Message;
+import org.apache.helix.zookeeper.datamodel.ZNRecord;
+import org.apache.helix.zookeeper.zkclient.exception.ZkException;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+
+public class TestStatusUpdateUtil extends ZkTestBase {
+  private String clusterName = TestHelper.getTestClassName();
+  static {
+    System.clearProperty(SystemPropertyKeys.STATEUPDATEUTIL_ERROR_LOG_ENABLED);
+  }
+
+  @Test
+  public void testDisableErrorLogByDefault() throws Exception {

Review comment:
       It is better to add both positive and negative tests in here. The main purpose of the other test is not testing error log though.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] lei-xia commented on a change in pull request #1487: Make enable error log to ZK from participant or controller configurable

Posted by GitBox <gi...@apache.org>.
lei-xia commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r513821364



##########
File path: helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
##########
@@ -55,6 +56,12 @@
 public class StatusUpdateUtil {
   static Logger _logger = LoggerFactory.getLogger(StatusUpdateUtil.class);
 
+  public static final boolean ERROR_LOG_TO_ZK_ENABLED;
+  static {
+    String valueString = System.getProperty(SystemPropertyKeys.STATEUPDATEUTIL_ERROR_LOG_ENABLED, "");
+    ERROR_LOG_TO_ZK_ENABLED = valueString.equals("enabled") ? true : false;

Review comment:
       Please use HelixUtil.getSystemPropertyAsBoolean(), it allows you to specify the default value there in the method.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] pkuwm merged pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
pkuwm merged pull request #1487:
URL: https://github.com/apache/helix/pull/1487


   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on a change in pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r520889096



##########
File path: helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
##########
@@ -492,47 +496,39 @@ void publishStatusUpdateRecord(ZNRecord record, Message message, Level level,
 
     Builder keyBuilder = accessor.keyBuilder();
     if (!_recordedMessages.containsKey(message.getMsgId())) {
-      if (isController) {
-        accessor
-            .updateProperty(keyBuilder.controllerTaskStatus(statusUpdateSubPath, statusUpdateKey),
-                new StatusUpdate(createMessageLogRecord(message)));
+      ZNRecord statusUpdateRecord = createMessageLogRecord(message);
+      PropertyKey propertyKey;
 
+      if (isController) {
+        propertyKey = keyBuilder.controllerTaskStatus(statusUpdateSubPath, statusUpdateKey);
+        accessor.updateProperty(propertyKey, new StatusUpdate(statusUpdateRecord));

Review comment:
       fixed.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] dasahcc commented on a change in pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
dasahcc commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r514598225



##########
File path: helix-core/src/main/java/org/apache/helix/util/HelixUtil.java
##########
@@ -470,11 +471,26 @@ public static int getSystemPropertyAsInt(String propertyKey, int propertyDefault
   }
 
   /**
-   * Get the value of system property
+   * Get the boolean value of system property
    * @param propertyKey
    * @param propertyDefaultValue
    * @return
    */
+  public static boolean getSystemPropertyAsBoolean(String propertyKey, String propertyDefaultValue) {

Review comment:
       +1. Unless you need some error handling in the function.

##########
File path: helix-common/src/main/java/org/apache/helix/SystemPropertyKeys.java
##########
@@ -82,4 +82,6 @@
   // System Property Metadata Store Directory Server endpoint key
   public static final String MSDS_SERVER_ENDPOINT_KEY =
       MetadataStoreRoutingConstants.MSDS_SERVER_ENDPOINT_KEY;
+
+  public static final String STATEUPDATEUTIL_ERROR_LOG_ENABLED = "helix.StateUpdateUtil.errorLog.enabled";

Review comment:
       We have a class ZkSystemPropertyKeys to hold this kind of system property. Please put this there.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on a change in pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r520889248



##########
File path: helix-common/src/main/java/org/apache/helix/SystemPropertyKeys.java
##########
@@ -82,4 +82,6 @@
   // System Property Metadata Store Directory Server endpoint key
   public static final String MSDS_SERVER_ENDPOINT_KEY =
       MetadataStoreRoutingConstants.MSDS_SERVER_ENDPOINT_KEY;
+
+  public static final String STATEUPDATEUTIL_ERROR_LOG2ZK_ENABLED = "helix.StateUpdateUtil.errorLog.enabled";

Review comment:
       changed.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] pkuwm commented on a change in pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
pkuwm commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r521119745



##########
File path: helix-core/src/test/java/org/apache/helix/integration/manager/TestParticipantManager.java
##########
@@ -66,6 +66,9 @@
 public class TestParticipantManager extends ZkTestBase {
   private MBeanServer _server = ManagementFactory.getPlatformMBeanServer();
   private String clusterName = TestHelper.getTestClassName();
+  static {
+    System.setProperty(SystemPropertyKeys.STATEUPDATEUTIL_ERROR_PERSISTENCY_ENABLED, "true");

Review comment:
       The system property is JVM level. If we don't unset the config, later tests will be using this config. Maybe there are no tests using the config yet. But I suggest, as a good practice, we also unset the config to make unit tests isolated, ensuring other tests won't be impacted by this test's configs.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on a change in pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r520886902



##########
File path: helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
##########
@@ -560,6 +556,10 @@ void publishStatusUpdateRecord(ZNRecord record, Message message, Level level,
    */
   void publishErrorRecord(ZNRecord record, String instanceName, String updateSubPath,
       String updateKey, String sessionId, HelixDataAccessor accessor, boolean isController) {
+    _logger.error("StatusUpdate Error record: {}", record);

Review comment:
       This is not a concern. Previously the issue is that N participant would write the log to one Zk quorum at the same time repeatedly. Here, we are writing to N participant at the same time. If this is a concern, we need to revisit all the participant side logging then.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] pkuwm commented on a change in pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
pkuwm commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r513892156



##########
File path: helix-core/src/main/java/org/apache/helix/util/HelixUtil.java
##########
@@ -62,6 +62,7 @@
 import org.apache.helix.model.ResourceAssignment;
 import org.apache.helix.model.ResourceConfig;
 import org.apache.helix.model.StateModelDefinition;
+import org.apache.helix.tools.ClusterVerifiers.StrictMatchExternalViewVerifier;

Review comment:
       This import is not used.

##########
File path: helix-core/src/main/java/org/apache/helix/util/HelixUtil.java
##########
@@ -470,11 +471,26 @@ public static int getSystemPropertyAsInt(String propertyKey, int propertyDefault
   }
 
   /**
-   * Get the value of system property
+   * Get the boolean value of system property
    * @param propertyKey
    * @param propertyDefaultValue
    * @return
    */
+  public static boolean getSystemPropertyAsBoolean(String propertyKey, String propertyDefaultValue) {

Review comment:
       We don't have to create this method to be redundant.
   Simply, `Boolean.getBoolean(propertyKey, propertyDefaultValue)` is already what is needed, right?

##########
File path: helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
##########
@@ -560,6 +565,10 @@ void publishStatusUpdateRecord(ZNRecord record, Message message, Level level,
    */
   void publishErrorRecord(ZNRecord record, String instanceName, String updateSubPath,
       String updateKey, String sessionId, HelixDataAccessor accessor, boolean isController) {
+    _logger.error("StatusUpdate Error record: {}", record.toString());

Review comment:
       Nit, `record.toString()` is redundant, `record` is enough as `toString()` would be auto called.

##########
File path: helix-core/src/test/java/org/apache/helix/integration/manager/TestParticipantManager.java
##########
@@ -66,6 +66,9 @@
 public class TestParticipantManager extends ZkTestBase {
   private MBeanServer _server = ManagementFactory.getPlatformMBeanServer();
   private String clusterName = TestHelper.getTestClassName();
+  static {
+    System.setProperty(SystemPropertyKeys.STATEUPDATEUTIL_ERROR_LOG_ENABLED, "true");

Review comment:
       Can you help me understand why you set the property here, but clear it in `TestStatusUpdateUtil`? Why do we not put both in the test method? Otherwise, the system config would affect other tests, right?

##########
File path: helix-core/src/test/java/org/apache/helix/util/TestStatusUpdateUtil.java
##########
@@ -0,0 +1,76 @@
+package org.apache.helix.util;
+

Review comment:
       Missing apache license. Maybe you could setup apache license in your intellij?

##########
File path: helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
##########
@@ -55,6 +56,10 @@
 public class StatusUpdateUtil {
   static Logger _logger = LoggerFactory.getLogger(StatusUpdateUtil.class);
 
+  public static final boolean ERROR_LOG_TO_ZK_ENABLED =
+      HelixUtil.getSystemPropertyAsBoolean(SystemPropertyKeys.STATEUPDATEUTIL_ERROR_LOG_ENABLED, "false");

Review comment:
       `Boolean.getBoolean(propertyKey, propertyDefaultValue)` is simple and good enough?

##########
File path: helix-core/src/test/java/org/apache/helix/util/TestStatusUpdateUtil.java
##########
@@ -0,0 +1,76 @@
+package org.apache.helix.util;
+
+import org.apache.helix.HelixConstants;
+import org.apache.helix.PropertyPathBuilder;
+import org.apache.helix.SystemPropertyKeys;
+import org.apache.helix.TestHelper;
+import org.apache.helix.common.ZkTestBase;
+import org.apache.helix.integration.manager.MockParticipantManager;
+import org.apache.helix.messaging.handling.HelixStateTransitionHandler;
+import org.apache.helix.model.Message;
+import org.apache.helix.zookeeper.datamodel.ZNRecord;
+import org.apache.helix.zookeeper.zkclient.exception.ZkException;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+
+public class TestStatusUpdateUtil extends ZkTestBase {
+  private String clusterName = TestHelper.getTestClassName();
+  static {
+    System.clearProperty(SystemPropertyKeys.STATEUPDATEUTIL_ERROR_LOG_ENABLED);
+  }
+
+  @Test
+  public void testDisableErrorLogByDefault() throws Exception {
+    StatusUpdateUtil _statusUpdateUtil = new StatusUpdateUtil();
+    int n = 1;
+
+    Exception e = new RuntimeException("test exception");
+
+    TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
+        "localhost", // participant name prefix
+        "TestDB", // resource name prefix
+        1, // resources
+        1, // partitions per resource
+        n, // number of nodes
+        1, // replicas
+        "MasterSlave", true);
+
+    MockParticipantManager[] participants = new MockParticipantManager[n];
+
+    for (int i = 0; i < n; i++) {
+      String instanceName = "localhost_" + (12918 + i);
+      participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
+      participants[i].syncStart();
+    }
+
+    Message message = new Message(Message.MessageType.STATE_TRANSITION, "Some unique id");
+    message.setSrcName("cm-instance-0");
+    message.setTgtSessionId(participants[0].getSessionId());
+    message.setFromState("Offline");
+    message.setToState("Slave");
+    message.setPartitionName("TestDB_0");
+    message.setMsgId("Some unique message id");
+    message.setResourceName("TestDB");
+    message.setTgtName("localhost_12918");
+    message.setStateModelDef("MasterSlave");
+    message.setStateModelFactoryName(HelixConstants.DEFAULT_STATE_MODEL_FACTORY);
+    _statusUpdateUtil.logError(message, HelixStateTransitionHandler.class, e,
+        "test status update", participants[0]);
+
+    // assert by default, not logged to Zookeeper
+    String errPath = PropertyPathBuilder.instanceError(clusterName, "localhost_12918",
+        participants[0].getSessionId(),
+        "TestDB", "TestDB_0");
+    try {
+      ZNRecord error = _gZkClient.readData(errPath);
+      Assert.fail("not expecting being able to send error logs to ZK by default.");
+    } catch (ZkException zke) {
+      Assert.assertTrue(true);

Review comment:
       Why `assertTrue(True);` which is always true? Just put a comment it is expected. Or to be more accurate, we can assert the exception message to ensure the exception is the expected one not others(same exception type but different message thrown from other places). 




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] lei-xia commented on a change in pull request #1487: Make enable error log to ZK from participant or controller configurable

Posted by GitBox <gi...@apache.org>.
lei-xia commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r513878022



##########
File path: helix-core/src/test/java/org/apache/helix/util/TestStatusUpdateUtil.java
##########
@@ -0,0 +1,76 @@
+package org.apache.helix.util;
+
+import org.apache.helix.HelixConstants;
+import org.apache.helix.PropertyPathBuilder;
+import org.apache.helix.SystemPropertyKeys;
+import org.apache.helix.TestHelper;
+import org.apache.helix.common.ZkTestBase;
+import org.apache.helix.integration.manager.MockParticipantManager;
+import org.apache.helix.messaging.handling.HelixStateTransitionHandler;
+import org.apache.helix.model.Message;
+import org.apache.helix.zookeeper.datamodel.ZNRecord;
+import org.apache.helix.zookeeper.zkclient.exception.ZkException;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+
+public class TestStatusUpdateUtil extends ZkTestBase {
+  private String clusterName = TestHelper.getTestClassName();
+  static {
+    System.clearProperty(SystemPropertyKeys.STATEUPDATEUTIL_ERROR_LOG_ENABLED);
+  }
+
+  @Test
+  public void testDisableErrorLogByDefault() throws Exception {

Review comment:
       Can you test enable it by the new config?




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] jiajunwang commented on a change in pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
jiajunwang commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r516239010



##########
File path: helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
##########
@@ -560,6 +565,10 @@ void publishStatusUpdateRecord(ZNRecord record, Message message, Level level,
    */
   void publishErrorRecord(ZNRecord record, String instanceName, String updateSubPath,
       String updateKey, String sessionId, HelixDataAccessor accessor, boolean isController) {
+    _logger.error("StatusUpdate Error record: {}", record.toString());
+    if (!ERROR_LOG_TO_ZK_ENABLED) {

Review comment:
       I'm fine with both designs. But as I mentioned, this change is half-way. Please either ensure that the source of truth is with the log for ALL the status util call (including log error, log status, etc.) or please don't log here otherwise the util is mixed up with some methods with log and the others don't.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] lei-xia commented on a change in pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
lei-xia commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r514322257



##########
File path: helix-common/src/main/java/org/apache/helix/SystemPropertyKeys.java
##########
@@ -82,4 +82,6 @@
   // System Property Metadata Store Directory Server endpoint key
   public static final String MSDS_SERVER_ENDPOINT_KEY =
       MetadataStoreRoutingConstants.MSDS_SERVER_ENDPOINT_KEY;
+
+  public static final String STATEUPDATEUTIL_ERROR_LOG_ENABLED = "helix.StateUpdateUtil.errorLog.enabled";

Review comment:
       Again, we are disabling log to ZK, not disabling error log (to log file) at all, right?




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on a change in pull request #1487: Make enable error log to ZK from participant or controller configurable

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r513845284



##########
File path: helix-core/src/test/java/org/apache/helix/integration/manager/TestParticipantManager.java
##########
@@ -66,6 +66,9 @@
 public class TestParticipantManager extends ZkTestBase {
   private MBeanServer _server = ManagementFactory.getPlatformMBeanServer();
   private String clusterName = TestHelper.getTestClassName();
+  static {
+    System.setProperty(SystemPropertyKeys.STATEUPDATEUTIL_ERROR_LOG_ENABLED, "enabled");

Review comment:
       In this test, here we are setting this property so that later test which asserting existence of error record in Zk won't fail. HelixUtil does not apply here as it is used to retrieve record.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] jiajunwang commented on a change in pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
jiajunwang commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r520261433



##########
File path: helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
##########
@@ -492,47 +496,39 @@ void publishStatusUpdateRecord(ZNRecord record, Message message, Level level,
 
     Builder keyBuilder = accessor.keyBuilder();
     if (!_recordedMessages.containsKey(message.getMsgId())) {
-      if (isController) {
-        accessor
-            .updateProperty(keyBuilder.controllerTaskStatus(statusUpdateSubPath, statusUpdateKey),
-                new StatusUpdate(createMessageLogRecord(message)));
+      ZNRecord statusUpdateRecord = createMessageLogRecord(message);
+      PropertyKey propertyKey;
 
+      if (isController) {
+        propertyKey = keyBuilder.controllerTaskStatus(statusUpdateSubPath, statusUpdateKey);
+        accessor.updateProperty(propertyKey, new StatusUpdate(statusUpdateRecord));

Review comment:
       nit, we can move this line out of the if-else block too.

##########
File path: helix-common/src/main/java/org/apache/helix/SystemPropertyKeys.java
##########
@@ -82,4 +82,6 @@
   // System Property Metadata Store Directory Server endpoint key
   public static final String MSDS_SERVER_ENDPOINT_KEY =
       MetadataStoreRoutingConstants.MSDS_SERVER_ENDPOINT_KEY;
+
+  public static final String STATEUPDATEUTIL_ERROR_LOG2ZK_ENABLED = "helix.StateUpdateUtil.errorLog.enabled";

Review comment:
       I thought more about this configuration. Can we directly make it an enum now instead of changing it later? Otherwise, we will need to deprecate this item and go through the painful backward compatibility checklist in the future.
   
   I suggest making it STATEUPDATE_ERROR_REPORTING_CHANNEL.

##########
File path: helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
##########
@@ -492,47 +496,39 @@ void publishStatusUpdateRecord(ZNRecord record, Message message, Level level,
 
     Builder keyBuilder = accessor.keyBuilder();
     if (!_recordedMessages.containsKey(message.getMsgId())) {
-      if (isController) {
-        accessor
-            .updateProperty(keyBuilder.controllerTaskStatus(statusUpdateSubPath, statusUpdateKey),
-                new StatusUpdate(createMessageLogRecord(message)));
+      ZNRecord statusUpdateRecord = createMessageLogRecord(message);
+      PropertyKey propertyKey;
 
+      if (isController) {
+        propertyKey = keyBuilder.controllerTaskStatus(statusUpdateSubPath, statusUpdateKey);
+        accessor.updateProperty(propertyKey, new StatusUpdate(statusUpdateRecord));
       } else {
-
-        PropertyKey propertyKey =
+        propertyKey =
             keyBuilder.stateTransitionStatus(instanceName, sessionId, statusUpdateSubPath,
                 statusUpdateKey);
-
-        ZNRecord statusUpdateRecord = createMessageLogRecord(message);
-
-        // For now write participant StatusUpdates to log4j.
-        // we are using restlet as another data channel to report to controller.
-        if (_logger.isTraceEnabled()) {
-          _logger.trace("StatusUpdate path:" + propertyKey.getPath() + ", updates:"
-              + statusUpdateRecord);
-        }
         accessor.updateProperty(propertyKey, new StatusUpdate(statusUpdateRecord));
+      }
 
+      if (_logger.isTraceEnabled()) {
+        _logger.trace("StatusUpdate path:" + propertyKey.getPath() + ", updates:"
+            + statusUpdateRecord);
       }
       _recordedMessages.put(message.getMsgId(), message.getMsgId());
     }
 
+    PropertyKey propertyKey;
     if (isController) {
-      accessor.updateProperty(
-          keyBuilder.controllerTaskStatus(statusUpdateSubPath, statusUpdateKey), new StatusUpdate(
-              record));
+      propertyKey = keyBuilder.controllerTaskStatus(statusUpdateSubPath, statusUpdateKey);
+      accessor.updateProperty(propertyKey, new StatusUpdate(record));

Review comment:
       same here.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] lei-xia commented on a change in pull request #1487: Make enable error log to ZK from participant or controller configurable

Posted by GitBox <gi...@apache.org>.
lei-xia commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r513799416



##########
File path: helix-common/src/main/java/org/apache/helix/SystemPropertyKeys.java
##########
@@ -82,4 +82,6 @@
   // System Property Metadata Store Directory Server endpoint key
   public static final String MSDS_SERVER_ENDPOINT_KEY =
       MetadataStoreRoutingConstants.MSDS_SERVER_ENDPOINT_KEY;
+
+  public static final String STATEUPDATEUTIL_ERROR_LOG_ENABLED = "helix.StateUpdateUtil.errorLog.enabled";

Review comment:
       minor: "helix.StateUpdateUtil.errorLogToZK.enabled"?  We still log error to local logfile, right?




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on a change in pull request #1487: Add a configuration option to allow enable/disable writing error log to ZK

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r521109725



##########
File path: helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
##########
@@ -55,6 +56,9 @@
 public class StatusUpdateUtil {
   static Logger _logger = LoggerFactory.getLogger(StatusUpdateUtil.class);
 
+  public static final boolean ERROR_LOG_TO_ZK_ENABLED =

Review comment:
       Actually it is not the case. Making it private won't work as I just test. I am not an expert in this area. If you know other trick, let me know.
   

##########
File path: helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
##########
@@ -55,6 +56,9 @@
 public class StatusUpdateUtil {
   static Logger _logger = LoggerFactory.getLogger(StatusUpdateUtil.class);
 
+  public static final boolean ERROR_LOG_TO_ZK_ENABLED =

Review comment:
       Actually it is not the case. Making it private won't work as I just tested. I am not an expert in this area. If you know other trick, let me know.
   




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on a change in pull request #1487: Make enable error log to ZK from participant or controller configurable

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on a change in pull request #1487:
URL: https://github.com/apache/helix/pull/1487#discussion_r513845622



##########
File path: helix-core/src/main/java/org/apache/helix/util/StatusUpdateUtil.java
##########
@@ -55,6 +56,12 @@
 public class StatusUpdateUtil {
   static Logger _logger = LoggerFactory.getLogger(StatusUpdateUtil.class);
 
+  public static final boolean ERROR_LOG_TO_ZK_ENABLED;
+  static {
+    String valueString = System.getProperty(SystemPropertyKeys.STATEUPDATEUTIL_ERROR_LOG_ENABLED, "");
+    ERROR_LOG_TO_ZK_ENABLED = valueString.equals("enabled") ? true : false;

Review comment:
       There is only HelixUtil.getSystemPropertyAsInt/Long, no asBoolean(). Let me add as Boolean then, make the changes a little bit wider.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org