[ 
https://issues.apache.org/jira/browse/NIFI-1164?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15058665#comment-15058665
 ] 

ASF GitHub Bot commented on NIFI-1164:
--------------------------------------

GitHub user olegz opened a pull request:

    https://github.com/apache/nifi/pull/141

    NIFI-1164 Fixed race condition and refactored

    Changed ControllerServiceNode by adding enable(..), disable(..) and 
isActive() operations. See javadocs for more details in both 
ControllerServiceNode and StandardControllerServiceNode
    
    Refactored service enable/disable logic in StandardProcessScheduler and 
StandardControllerServiceNode . Below are some of the notes:
    - No need for resetting class loader since its going to derive from the 
class loader of the service. In other words any classes that aren’t loaded and 
will be loaded within the scope of the already loaded service will be loaded by 
the class lower of that service
    - No need to control 'scheduleState.isScheduled()’ since the logic has 
changed to use CAS operation on state update and the service state change is 
now atomic.
    - Removed Thread.sleep(..) and while(true) loop in favor of rescheduling 
re-tries achieving better thread utilization since the thread that would 
normally block in Thread.sleep(..) is now reused.
    - Added tests and validated that the race condition no longer happening
    
    Added additional logic that allows the initiation of the service disabling 
while it is in ENABLING state. See javadoc of 
StandardProcessScheduler.enable/disable for more details.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/olegz/nifi NIFI-1164

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nifi/pull/141.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #141
    
----
commit 0727b2d31e1b552436c6c16df25dcbfcfcec5a3b
Author: Oleg Zhurakousky <[email protected]>
Date:   2015-12-15T18:21:00Z

    NIFI-1164 Fixed race condition and refactored
    
    Changed ControllerServiceNode by adding enable(..), disable(..) and 
isActive() operations. See javadocs for more details in both 
ControllerServiceNode and StandardControllerServiceNode
    
    Refactored service enable/disable logic in StandardProcessScheduler and 
StandardControllerServiceNode . Below are some of the notes:
    - No need for resetting class loader since its going to derive from the 
class loader of the service. In other words any classes that aren’t loaded and 
will be loaded within the scope of the already loaded service will be loaded by 
the class lower of that service
    - No need to control 'scheduleState.isScheduled()’ since the logic has 
changed to use CAS operation on state update and the service state change is 
now atomic.
    - Removed Thread.sleep(..) and while(true) loop in favor of rescheduling 
re-tries achieving better thread utilization since the thread that would 
normally block in Thread.sleep(..) is now reused.
    - Added tests and validated that the race condition no longer happening
    
    Added additional logic that allows the initiation of the service disabling 
while it is in ENABLING state. See javadoc of 
StandardProcessScheduler.enable/disable for more details.

----


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

Reply via email to