[
https://issues.apache.org/jira/browse/NIFI-1164?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15007232#comment-15007232
]
ASF GitHub Bot commented on NIFI-1164:
--------------------------------------
Github user markap14 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/126#discussion_r44975323
--- Diff:
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceProvider.java
---
@@ -545,23 +546,16 @@ public void enableReferencingServices(final
ControllerServiceNode serviceNode) {
}
private void enableReferencingServices(final ControllerServiceNode
serviceNode, final List<ControllerServiceNode> recursiveReferences) {
- if (serviceNode.getState() != ControllerServiceState.ENABLED &&
serviceNode.getState() != ControllerServiceState.ENABLING) {
+ if (serviceNode.getState() != ControllerServiceState.ENABLING &&
serviceNode.getState() != ControllerServiceState.ENABLED) {
serviceNode.verifyCanEnable(new
HashSet<>(recursiveReferences));
}
final Set<ControllerServiceNode> ifEnabled = new HashSet<>();
- final List<ControllerServiceNode> toEnable =
findRecursiveReferences(serviceNode, ControllerServiceNode.class);
- for (final ControllerServiceNode nodeToEnable : toEnable) {
+ for (final ControllerServiceNode nodeToEnable :
recursiveReferences) {
final ControllerServiceState state = nodeToEnable.getState();
- if (state != ControllerServiceState.ENABLED && state !=
ControllerServiceState.ENABLING) {
+ if (state != ControllerServiceState.ENABLING && state !=
ControllerServiceState.ENABLED) {
nodeToEnable.verifyCanEnable(ifEnabled);
ifEnabled.add(nodeToEnable);
- }
- }
-
- for (final ControllerServiceNode nodeToEnable : toEnable) {
--- End diff --
@olegz - I agree with all of the changes made except for this. Previously,
we iterated over the list twice, because the first time we want to verify that
all services can be enabled. If any service cannot be enabled, then we want to
enable none of them (all or nothing). With the change here, we could enable a
few services, and then find that the next service cannot be enabled and throw
an Exception, having enabled just a few of them.
> Race condition during initialization of ControllerServices - (part due)
> -----------------------------------------------------------------------
>
> Key: NIFI-1164
> URL: https://issues.apache.org/jira/browse/NIFI-1164
> Project: Apache NiFi
> Issue Type: Bug
> Components: Core Framework
> Affects Versions: 0.3.0
> Reporter: Oleg Zhurakousky
> Assignee: Oleg Zhurakousky
> Fix For: 0.4.0
>
>
> Similar to NIFI-1143, but the exception is happening in the different place
> {code}testConcurrencyWithEnablingReferencingServicesGraph(org.apache.nifi.controller.service.TestStandardControllerServiceProvider)
> Time elapsed: 0.162 sec <<< ERROR!
> java.lang.IllegalStateException: ServiceB[id=4] cannot be enabled because it
> is not disabled
> at
> org.apache.nifi.controller.service.StandardControllerServiceNode.verifyCanEnable(StandardControllerServiceNode.java:183)
> at
> org.apache.nifi.controller.service.StandardControllerServiceProvider.enableReferencingServices(StandardControllerServiceProvider.java:549)
> at
> org.apache.nifi.controller.service.StandardControllerServiceProvider.enableReferencingServices(StandardControllerServiceProvider.java:544)
> at
> org.apache.nifi.controller.service.TestStandardControllerServiceProvider.testEnableReferencingServicesGraph(TestStandardControllerServiceProvider.java:154)
> at
> org.apache.nifi.controller.service.TestStandardControllerServiceProvider.testConcurrencyWithEnablingReferencingServicesGraph(TestStandardControllerServiceProvider.java:124)
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)