markap14 commented on pull request #4798:
URL: https://github.com/apache/nifi/pull/4798#issuecomment-772666915


   I was able to cause an error with the following scenario. Given, the 
scenario is contrived, but it can definitely happen "in the wild" based on the 
timing of events when nodes and joining/rejoining to cluster. Steps to 
reproduce (assumes a 2 node cluster:
   
   1. Create dataflow: GenerateFlowFile -> DebugFlow -> UpdateAttribute
   2. Set DebugFlow's `@OnScheduled Pause Time` property to `1 min`
   3. Start the processor
   4. Shut down Node 2
   5. Remove Node 2 from the cluster
   6. Stop processor, wait for thread to complete
   7. Click Run Once
   8. While processor is running, start Node 2
   
   Node 2 will now join the cluster. However, when the single trigger 
completes, we will have Node 1 with a Scheduled State of STOPPED, and Node 2 
with a Scheduled State of RUNNING. Node 2 did not properly inherit the 
cluster's Scheduled State for the Processor when the Scheduled State was 
RUN_ONCE.
   
   I think the issue is because in `StandardFlowSynchronizer` we don't take the 
`RUN_ONCE` state into account in the `updateProcessGroup` method. On line 918, 
we have the following block:
   
   ```
                           case STOPPED:
                               if (procState == ScheduledState.DISABLED) {
                                   
procNode.getProcessGroup().enableProcessor(procNode);
                               } else if (procState == ScheduledState.RUNNING) {
                                   
controller.stopProcessor(procNode.getProcessGroupIdentifier(), 
procNode.getIdentifier());
                               }
                               break;
   ```
   
   I think we need to change this to something like:
   ```
   case STOPPED:
   case RUN_ONCE:
                               if (procState == ScheduledState.DISABLED) {
                                   
procNode.getProcessGroup().enableProcessor(procNode);
                               } else if (procState == ScheduledState.RUNNING 
|| procState == ScheduledState.RUN_ONCE) {
                                   
controller.stopProcessor(procNode.getProcessGroupIdentifier(), 
procNode.getIdentifier());
                               }
                               break;
   ```


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


Reply via email to