pvillard31 commented on code in PR #11664:
URL: https://github.com/apache/nifi/pull/11664#discussion_r3980845946


##########
nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java:
##########
@@ -657,117 +661,137 @@ public CompletableFuture<Void> enable(final 
ScheduledExecutorService scheduler,
         final AtomicLong validationDelay = new AtomicLong(0);
         final ControllerServiceProvider controllerServiceProvider = 
this.serviceProvider;
         final StandardControllerServiceNode serviceNode = this;
-        scheduler.execute(new Runnable() {
+        final Runnable enablingRunnable = new Runnable() {
             @Override
             public void run() {
                 final ConfigurationContext configContext = 
providedConfigurationContext == null
                     ? new StandardConfigurationContext(serviceNode, 
controllerServiceProvider, null)
                     : providedConfigurationContext;
+                boolean enabled = false;
+                synchronized (active) {
+                    if (!active.get() || !stateTransition.isEnabling(future)) {

Review Comment:
   Could the transition to `ENABLING` and setting `active` to true earlier in 
`enable()` be coordinated with `disable()` under the same lock? If `disable()` 
completes after `transitionToEnabling()` but before `active` is set, the enable 
thread can set `active` back to true while the state is already `DISABLED`; 
this check then rejects the stale enable request, and later enable requests 
return early because `isActive()` is true.



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

To unsubscribe, e-mail: [email protected]

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

Reply via email to