karaf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From J. Brébec (JIRA) <j...@apache.org>
Subject [jira] [Commented] (KARAF-6074) Race condition between the FeaturesService and FeatureDeploymentListener
Date Wed, 03 Apr 2019 17:14:00 GMT

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

J. Brébec commented on KARAF-6074:
----------------------------------

This issue happen only on the first start, and can happen randomly because it's a race condition
between two threads : the thread activating the osgi framework (and calling the activators),
and the thread doing the provisioning of features.

It happens on the following scenario :
 # First start
 # The activator of the bundle feature-core is called. It's not blocking : it spawn a new
thread to do the provisioning. the FeaturesService is registered in osgi here
 # Let's assume the thread created in the previous step can't execute (or is slow), maybe
because the hardware have only one core, or whatever reason : the FeaturesServiceImpl.lastDeploymentStatus
is DEPLOYMENT_FINISHED. You can simulate this step easily with a debugger, with a break-point
in [executor.submit|https://github.com/apache/karaf/blob/karaf-4.2.4/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java#L994]
 # The activator of the bundle "feature-deployment" is called. It can access the FeaturesService
because of step 2.
 # It then register a deployment listener : this listener is called back with the status DEPLOYMENT_FINISHED.
Because step 3 is not finished, the root region doesn't exist and the listener fails with
a NPE

I can provide you other details/artefacts, but I don't have access for now to a running instance.

> Race condition between the FeaturesService and FeatureDeploymentListener
> ------------------------------------------------------------------------
>
>                 Key: KARAF-6074
>                 URL: https://issues.apache.org/jira/browse/KARAF-6074
>             Project: Karaf
>          Issue Type: Bug
>          Components: karaf
>    Affects Versions: 4.2.2, 4.2.4
>         Environment: Karaf 4.2.2 Windows 7 and Equinox
>            Reporter: J. Brébec
>            Assignee: Grzegorz Grzybek
>            Priority: Critical
>             Fix For: 4.2.3
>
>
> On the first start of a custom Karaf container (4.2.2), the logs shows a log of NPE in FeatureDeploymentListener.
> After some analysis of this Exception, it's look like a race condition between the FeaturesService
and the FeatureDeploymentListener :
>  # The FeaturesService starts and launch a provisioning in another thread
>  # a FeatureDeploymentListener is registered, and call bundleChanged for every bundle
installed (the startup bundles)
>  # It calls FeaturesService.state.requirements and get an empty map
>  # Updating the root regions in the requirements map fails with an NPE
>  # Some times later, the deployment task launched at step 1 is started, and FeaturesService.saveState()
is called : state.requirements."root region" is initialised
> The step 5 is executed in another thread, so it can happens before step 2 (and it works)
or after, causing this NPE
> Moreover, some methods in FeaturesService assume that state.requirements."root region"
exists. There are probably others npe here.
>  
> {code:java}
> 14:37:55.668 ERROR [activator-1-thread-2] Unable to update deployed features for bundle:
org.eclipse.osgi - 3.12.100.v20180210-1608
> java.lang.NullPointerException: null
> at org.apache.karaf.deployer.features.FeatureDeploymentListener.bundleChanged(FeatureDeploymentListener.java:247)
[25:org.apache.karaf.deployer.features:4.2.2]
> at org.apache.karaf.deployer.features.FeatureDeploymentListener.init(FeatureDeploymentListener.java:95)
[25:org.apache.karaf.deployer.features:4.2.2]
> at org.apache.karaf.deployer.features.osgi.Activator.doStart(Activator.java:52) [25:org.apache.karaf.deployer.features:4.2.2]
> at org.apache.karaf.util.tracker.BaseActivator.run(BaseActivator.java:292) [25:org.apache.karaf.deployer.features:4.2.2]
> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
> at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message