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 2021/04/15 20:15:01 UTC

[GitHub] [helix] dasahcc commented on a change in pull request #1698: Fix unexpected result when resuming a cluster from paused/maintenance mode.

dasahcc commented on a change in pull request #1698:
URL: https://github.com/apache/helix/pull/1698#discussion_r614362946



##########
File path: helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
##########
@@ -1469,35 +1463,41 @@ private void shutdownPipeline(Thread thread, ClusterEventBlockingQueue queue)
     }
   }
 
-  private boolean updateControllerState(NotificationContext changeContext, PauseSignal signal,
-      boolean statusFlag) {
+  private boolean updateControllerState(PauseSignal signal, boolean statusFlag) {
     if (signal != null) {
-      // This logic is used for recording first time entering PAUSE/MAINTENCE mode
       if (!statusFlag) {
         statusFlag = true;
+        // This log is recorded for the first time entering PAUSE/MAINTENANCE mode
         logger.info(String.format("controller is now %s",
             (signal instanceof MaintenanceSignal) ? "in maintenance mode" : "paused"));
       }
     } else {
-      if (statusFlag) {
-        statusFlag = false;
-        logger.info("controller is now resumed from paused state");
-        String uid = UUID.randomUUID().toString().substring(0, 8);
-        ClusterEvent event = new ClusterEvent(_clusterName, ClusterEventType.Resume,
-            String.format("%s_%s", uid, Pipeline.Type.DEFAULT.name()));
-        event.addAttribute(AttributeName.EVENT_SESSION.name(),
-            changeContext.getManager().getSessionIdIfLead());
-        event.addAttribute(AttributeName.changeContext.name(), changeContext);
-        event.addAttribute(AttributeName.helixmanager.name(), changeContext.getManager());
-        event.addAttribute(AttributeName.AsyncFIFOWorkerPool.name(), _asyncFIFOWorkerPool);
-        enqueueEvent(_eventQueue, event);
-        enqueueEvent(_taskEventQueue,
-            event.clone(String.format("%s_%s", uid, Pipeline.Type.TASK.name())));
-      }
+      statusFlag = false;
     }
     return statusFlag;
   }
 
+  /**
+   * Trigger a Resume Event if the cluster is back to activated.
+   * @param changeContext
+   * @param prevPaused the previous paused status.
+   * @param prevInMaintenanceMode the previous in maintenance mode status.
+   */
+  private void triggerResumeEvent(NotificationContext changeContext, boolean prevPaused,
+      boolean prevInMaintenanceMode) {
+    /**
+     * WARNING: the logic here is tricky.
+     * 1. Only resume if not paused. So if the Maintenance mode is removed but the cluster is still
+     * paused, the resume event should not be sent.
+     * 2. Only send resume event if the status is changed back to active. So we don't send multiple
+     * event unnecessarily.
+     */
+    if (!_paused && (prevPaused || (prevInMaintenanceMode && !_inMaintenanceMode))) {

Review comment:
       Could this check let first event missed when leaderswitch? Because when leaderswitch, prevPaused is false and current paused is false as well.




-- 
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