You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Richard Ellis (Created) (JIRA)" <ji...@apache.org> on 2012/04/12 19:01:24 UTC
[jira] [Created] (FELIX-3456) Component ignores required static
service addition when in Activating state
Component ignores required static service addition when in Activating state
---------------------------------------------------------------------------
Key: FELIX-3456
URL: https://issues.apache.org/jira/browse/FELIX-3456
Project: Felix
Issue Type: Bug
Components: Declarative Services (SCR)
Affects Versions: scr-1.6.0
Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
Reporter: Richard Ellis
Priority: Critical
I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
This happens as follows:
12:30:59:317 Thread 1 - Registers Service B/257
12:30:59:320 Thread 2 - Registers Service A/258
12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
12:30:59:321 Thread 2 - Activating component
12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
There is a comment in DependencyManager#serviceAdded method:
// FELIX-1413: if the dependency is static and the component is
// satisfied (active) added services are not considered until
// the component is reactivated for other reasons.
This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
A simple fix would be to check the state of the component as well as if the service is static e.g.
replace if ( m_dependencyMetadata.isStatic() )
with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
There are other fixes that could be done by synchronizing more around service additions.
Is anyone willing to make this fix or does anyone have any thoughts about this issue?
Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "David Jencks (Updated) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
David Jencks updated FELIX-3456:
--------------------------------
Attachment: FELIX-3456-3.diff
This implementation synchronizes larger chunks of code and uses locks so that a possible deadlock will timeout. The idea is to have a queue of work to do. A thread will add its work to the queue and try to get the lock if it doesn't already have it. If it succeeds within the timeout then it will run all the work items in the queue.
I believe this means that unless there is a timeout, the work will complete before the thread returns. The work may get done on a different thread.
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Attachments: FELIX-3456-1.diff, FELIX-3456-3.diff
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "Richard Ellis (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13252653#comment-13252653 ]
Richard Ellis commented on FELIX-3456:
--------------------------------------
On second thoughts I'm not sure my proposed fix goes far enough because even though it allows the second service to attempt to be bound, there is no guarantee that this bind operation will complete in a timely enough fashion for the activate process triggered by the first service to complete successfully. I think some synchronization will probably be required.
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "David Jencks (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
David Jencks updated FELIX-3456:
--------------------------------
Attachment: FELIX-3456-8.diff
We're finding some deadlocks with the current code. Following some suggestions from Michael Fraenkel, I changed to a read-write lock for creating the component instance and a CAS strategy for registering the service. This patch is not complete, it doesn't deal with ServiceFactory or (I think) ComponentFactory and I didn't implement the backwards compatible lock wrapper yet, but I'm putting it out for comments anyway.
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Fix For: scr-1.6.2
>
> Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff, FELIX-3456-5.diff, FELIX-3456-5a.diff, FELIX-3456-5b.diff, FELIX-3456-7.diff, FELIX-3456-7a.diff, FELIX-3456-8.diff, FELIX-3456-fmeschbe-6.patch, FELIX-3456-fmeschbe.patch
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "David Jencks (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13278354#comment-13278354 ]
David Jencks commented on FELIX-3456:
-------------------------------------
>> makes the enable/activate and disable/deactivate happen per spec as
>> enable/disable immediate and activate/deactivate asynchronous.
>As I said before, these are already asynchronous because the BundleComponentActivator.enableComponent and .disableComponent schedule the actual call to activateInternal and deactivateInternal for asynchronous execution.
The activate/deactivate were already asynchronous but the enable/disable were too, which is contrary to the spec and IMO a pretty bad idea. This part of my change is to separate the enable from activate and disable from deactivate. I think we haven't heard of problems only because no one uses this much. But, maybe the requirement in the spec just makes no sense and I don't see why yet.
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff, FELIX-3456-5.diff, FELIX-3456-5a.diff, FELIX-3456-5b.diff, FELIX-3456-fmeschbe.patch
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "David Jencks (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
David Jencks updated FELIX-3456:
--------------------------------
Attachment: FELIX-3456-7a.diff
FELIX-3456-7.diff
I like most of your patch and appreciate your fixing the sync enable for default-enabled components.
There are still a couple problems:
1. I'd like a fair reentrant lock, doug lea's original doesn't appear to be fair. I tried to use the emory dcl backport-util-concurrent which does implement a fair lock but AFAICT it would require exporting sun.misc from the framework which I don't think is acceptable. So, I implemented something I think will work where the java.util.concurrent reentrant lock is used if available and if not doug lea's unfair lock.
2. There were some problems around state change and trying to activate while binding services. Basically the solution to 3317 is no longer relevant and we can simplify the code a bit more. The state change to Active has to happen earlier before checking the dependency managers or you always get the component created several times, registered, and then unregistered. We have enough locking already :-)
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff, FELIX-3456-5.diff, FELIX-3456-5a.diff, FELIX-3456-5b.diff, FELIX-3456-7.diff, FELIX-3456-7a.diff, FELIX-3456-fmeschbe-6.patch, FELIX-3456-fmeschbe.patch
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "David Jencks (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
David Jencks updated FELIX-3456:
--------------------------------
Attachment: FELIX-3456-5b.diff
FELIX-3456-5a.diff
FELIX-3456-5.diff
I think these are an OK solution to the concurrency problems. They use java 5 concurrency and don't yet address pre-1.5 compatibility.
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff, FELIX-3456-5.diff, FELIX-3456-5a.diff, FELIX-3456-5b.diff, FELIX-3456-fmeschbe.patch
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13286547#comment-13286547 ]
Felix Meschberger commented on FELIX-3456:
------------------------------------------
I have commited the final patch 7 in Rev. 1344701
Tests still pass. Please verify in your environment. Thanks.
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff, FELIX-3456-5.diff, FELIX-3456-5a.diff, FELIX-3456-5b.diff, FELIX-3456-7.diff, FELIX-3456-7a.diff, FELIX-3456-fmeschbe-6.patch, FELIX-3456-fmeschbe.patch
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "David Jencks (Updated) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
David Jencks updated FELIX-3456:
--------------------------------
Attachment: FELIX-3456-1.diff
This synchronized some state changes in Componentmanager and uses an AtomicInteger for DependencyManager.size. I realize that using modern concurrency techniques is going to require some debate :-) but I'm putting this out for review and testing.
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Attachments: FELIX-3456-1.diff
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "David Jencks (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13252637#comment-13252637 ]
David Jencks commented on FELIX-3456:
-------------------------------------
After a very brief look I don't understand how this would result in correct behavior. I think that if the state is "activating" we would need to wait until it gets back to "unsatisfied" and then try activateInternal again. Otherwise won't we be binding the service but not checking if all the activation conditions are met? What will check and get the service to activate if all the conditions are now met? How about if there are 3 required services and we only have 2 of them?
I think we need some thread synchronization and if the state is not unsatisified or active wait until it gets to one of those before proceeding.
As I said this is after a very brief look, please think carefully before agreeing with me :-)
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "Felix Meschberger (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13253605#comment-13253605 ]
Felix Meschberger commented on FELIX-3456:
------------------------------------------
Thanks for reporting. This is in fact an issue.
I am not against replacing the size int by an AtomicInteger; in the interest of concurrency stability this might make sense. (though this might prevent SCR from being used in pre-Java 5 setups; we still consider this requirement valid for SCR)
But I am not convinced with the state lock. This going to be dangerous for deadlocks because during activate and deactive services may be registered or unregistered, which may cause deadlocks: We currently have one single situation where we synchronize (creation of delayed component service instances) and we realize occasional deadlocks.
Thinking the other way around: We have some transient states during which events may happen which may get lost. One such transient state is the activating state. And this is such an event which may get lost. Another event may be a configuration update.
I have been contemplating some kind of event queuing and some way of processing such a queue when leaving the transient state.
In the concrete example:
T1 registers Service A, causes component into the ACTIVATING state
T2 registers Service B, enqueues event since component is ACTIVATING
T1 terminates ACTIVATING, checks queue and handles event.
The queue could be as simple as a list of Runnable on each component manager.
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Attachments: FELIX-3456-1.diff
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "David Jencks (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13274780#comment-13274780 ]
David Jencks commented on FELIX-3456:
-------------------------------------
I'm afraid I don't think the approach in FELIX-3456-fmeschbe.patch is workable. I have 3 main objections:
1. I don't think it is acceptable to return from a event that might have changed the state without doing the work. Thus I don't think any asynchronous processing is acceptable unless specifically mandated by the spec (as for enable/disable). One of my suggestions had a similar "queue work we can't do right now" approach and the results were too unpredictable.
2. A hardcoded wait time is a bad solution to the problem. You can avoid the fixed wait by using a lock with a timeout. Also this is a radically out of order proposal. In the half-second the state may have gone back and forth between e.g. active and inactive and enabled and disabled many times.
3. If you replace the delayAndCheck with a lock, or regard it as a new style of lock, the locks are too small. The locks should be around the entire event processing. The only part of the processing that can take any time is calling out to the framework and config admin, which has to happen in the locked region anyway. So locking the entire event processing won't take any longer and will make the effect of the code more possible to understand.
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff, FELIX-3456-fmeschbe.patch
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "David Jencks (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13280664#comment-13280664 ]
David Jencks commented on FELIX-3456:
-------------------------------------
oops, 7 is the full patch, 7a is a diff from your -6 patch.
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff, FELIX-3456-5.diff, FELIX-3456-5a.diff, FELIX-3456-5b.diff, FELIX-3456-7.diff, FELIX-3456-7a.diff, FELIX-3456-fmeschbe-6.patch, FELIX-3456-fmeschbe.patch
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Felix Meschberger updated FELIX-3456:
-------------------------------------
Attachment: FELIX-3456-fmeschbe.patch
Here is a patch following my earlier proposal with an added delay to give the component a chance to settle on a steady state.
This implements the activate, deactivate and disable methods in the Activating state which is the transient state active while the component is being activated in the Unsatisifed.activate method.
These implementations delay for 500ms and check the current state again (whether it is still Activating). If not, the original call is tried again on the AbstractComponentManager. If still Activating, a Runnable is enqueued which calls the original method again on the AbstractComponentManager.
The Unsatisifed.activate method checks whether there are any enqueued Runnable instances and executes them one after the other, if so.
This patch has a slight problem: It may treat reactivation (deactivate-then-activate) incorrectly in that deactivate might be queue while activate might be called directly. This could be solved by introducing a new reactivate method comprising both state transitions.
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff, FELIX-3456-fmeschbe.patch
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Resolved] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "David Jencks (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
David Jencks resolved FELIX-3456.
---------------------------------
Resolution: Fixed
Fix Version/s: (was: scr-1.6.2)
scr-1.8.0
This problem is fixed, although there are other concurrency problems remaining.
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Assignee: David Jencks
> Priority: Critical
> Fix For: scr-1.8.0
>
> Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff, FELIX-3456-5a.diff, FELIX-3456-5b.diff, FELIX-3456-5.diff, FELIX-3456-7a.diff, FELIX-3456-7.diff, FELIX-3456-8a.diff, FELIX-3456-8.diff, FELIX-3456-fmeschbe-6.patch, FELIX-3456-fmeschbe.patch
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Felix Meschberger updated FELIX-3456:
-------------------------------------
Attachment: FELIX-3456-fmeschbe-6.patch
Modified patch 5:
* Use Doug Lea's ReentrantLock from his concurrent library. Is also embedded in the final bundle.
* The satisfied state has to be set before creating the component in the Unsatisified.activate method. Otherwise a stack overflow may happen (if the component registers services in the activator to which it has a reference).
* Slight fix to the AbstractComponentManager.getSatisfiedState method due to moved state change (see above) for ComponentFactory component instances.
I checked this patch with our application, which seems to work.
I am still not fully convinced with locking and throwing. On the other hand this gives log messages in case of concurrency issues as opposed to today, where such issues are not recognized/recorded.
In the end I think, I can live with this patch now.
Does it fix your problem ?
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff, FELIX-3456-5.diff, FELIX-3456-5a.diff, FELIX-3456-5b.diff, FELIX-3456-fmeschbe-6.patch, FELIX-3456-fmeschbe.patch
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "Michael Fraenkel (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael Fraenkel updated FELIX-3456:
------------------------------------
Attachment: FELIX-3456-1.1.diff
The first patch needs to synchronize access when retrieving the actual Service.
There is a race when a component is activated and then registers its service. If you have multiple dependents, one of them can request the service before it completes all binds. Logically, the transition to REGISTERED is not complete until the service has completed registration.
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Issue Comment Edited] (FELIX-3456) Component ignores
required static service addition when in Activating state
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13269001#comment-13269001 ]
Felix Meschberger edited comment on FELIX-3456 at 5/5/12 4:33 PM:
------------------------------------------------------------------
Here is a patch following my earlier proposal with an added delay to give the component a chance to settle on a steady state.
This implements the activate, deactivate and disable methods in the Activating state which is the transient state active while the component is being activated in the Unsatisifed.activate method.
These implementations delay for 500ms and check the current state again (whether it is still Activating). If not, the original call is tried again on the AbstractComponentManager. If still Activating, a Runnable is enqueued which calls the original method again on the AbstractComponentManager.
The Unsatisifed.activate method checks whether there are any enqueued Runnable instances and executes them one after the other, if so.
This patch has a slight problem: It may treat reactivation (deactivate-then-activate) incorrectly in that deactivate might be enqueued while activate might be called directly. This could be solved by introducing a new reactivate method comprising both state transitions.
was (Author: fmeschbe):
Here is a patch following my earlier proposal with an added delay to give the component a chance to settle on a steady state.
This implements the activate, deactivate and disable methods in the Activating state which is the transient state active while the component is being activated in the Unsatisifed.activate method.
These implementations delay for 500ms and check the current state again (whether it is still Activating). If not, the original call is tried again on the AbstractComponentManager. If still Activating, a Runnable is enqueued which calls the original method again on the AbstractComponentManager.
The Unsatisifed.activate method checks whether there are any enqueued Runnable instances and executes them one after the other, if so.
This patch has a slight problem: It may treat reactivation (deactivate-then-activate) incorrectly in that deactivate might be queue while activate might be called directly. This could be solved by introducing a new reactivate method comprising both state transitions.
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff, FELIX-3456-fmeschbe.patch
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13277809#comment-13277809 ]
Felix Meschberger commented on FELIX-3456:
------------------------------------------
> makes the enable/activate and disable/deactivate happen per spec as
> enable/disable immediate and activate/deactivate asynchronous.
As I said before, these are already asynchronous because the BundleComponentActivator.enableComponent and .disableComponent schedule the actual call to activateInternal and deactivateInternal for asynchronous execution.
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff, FELIX-3456-5.diff, FELIX-3456-5a.diff, FELIX-3456-5b.diff, FELIX-3456-fmeschbe.patch
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Assigned] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "David Jencks (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
David Jencks reassigned FELIX-3456:
-----------------------------------
Assignee: David Jencks
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Assignee: David Jencks
> Priority: Critical
> Fix For: scr-1.6.2
>
> Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff, FELIX-3456-5.diff, FELIX-3456-5a.diff, FELIX-3456-5b.diff, FELIX-3456-7.diff, FELIX-3456-7a.diff, FELIX-3456-8.diff, FELIX-3456-8a.diff, FELIX-3456-fmeschbe-6.patch, FELIX-3456-fmeschbe.patch
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "Felix Meschberger (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13254080#comment-13254080 ]
Felix Meschberger commented on FELIX-3456:
------------------------------------------
> A colleague tried a completely asynchronous model for service events in scr and although start seemed to work,
> stopping resulted in a lot of work on stopped bundles and component objects
Been there done that ... SCR was fully asynchronous at one point in time.
Stopping failed miserably because services have been gone when the component was about to be stopped and expected statically bound services to still be available.
Startup worked correctly and the spec does not favor one or the other (I think there is nothing about synchronicity in the spec). I converted to synchronous startup to have better control during system startup (namely to have all components activated when the FRAMEWORK_STARTED event is fired by the framework). In fact, it is quite nice to have all components fuly handled once the bundle's STARTED or STOPPED event is fired. (This is one of my concerns with blueprint which is asynchronous and makes it hard to reason about system state).
Overall and in hindsight it looks like synchronous startup is preferable to asynchronous startup.
BTW: The last time I checked, Equinox DS was also fully synchronous.
> We might have an internal and external state.
In your proposal thread 2 waits for the lock and thus thread 1 and thread 2 are susceptive to deadlocks. Particularly if you take another service into account .... The reason for this is, that when a service is supplied we are called back from the framework and thus have to be extremely carefull since the framework may still hold locks (for example bundle locks during bundle start)
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Attachments: FELIX-3456-1.diff
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Felix Meschberger updated FELIX-3456:
-------------------------------------
Comment: was deleted
(was: ComponentContext.enable and .disable must set the enabled and disabled state immediately but any action resulting from this must be asynchronous. The current implementation violates the spec in that the status is not immediately set. But the actual action occurrs asynchronously as mandated in section 112.5.1.
This is to my knowledge the only explicit notion of timing. Particularly there is no requirement to either activate or deactivate components synchronously or asynchronously on SCR or bundle startup or stop. Experience showed me that any attempt to make these asynchronous (remember we had them both asynchronous at one point in time) had issues.
Stopping components asynchronously on bundle or SCR shutdown or service unregistration causes problems (been there done that).
Starting components asynchronously causes non-deterministic startup behaviour while not being much more stable with respect to deadlocks.
So, I really don't want to change that.
If we need to fix something to make ComponentContext.enable and .disable more spec compliant (setting the state immediately while doing the action asynchronously), we can do so....)
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff, FELIX-3456-5.diff, FELIX-3456-5a.diff, FELIX-3456-5b.diff, FELIX-3456-fmeschbe.patch
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Closed] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Felix Meschberger closed FELIX-3456.
------------------------------------
Close after release
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Assignee: David Jencks
> Priority: Critical
> Fix For: scr-1.6.2
>
> Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff, FELIX-3456-5a.diff, FELIX-3456-5b.diff, FELIX-3456-5.diff, FELIX-3456-7a.diff, FELIX-3456-7.diff, FELIX-3456-8a.diff, FELIX-3456-8.diff, FELIX-3456-fmeschbe-6.patch, FELIX-3456-fmeschbe.patch
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "David Jencks (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
David Jencks updated FELIX-3456:
--------------------------------
Attachment: FELIX-3456-8a.diff
same result as previous patch but applies to current trunk. I'm not sure how to functionally improve this, I'm tempted to suggest applying it.
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Fix For: scr-1.6.2
>
> Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff, FELIX-3456-5.diff, FELIX-3456-5a.diff, FELIX-3456-5b.diff, FELIX-3456-7.diff, FELIX-3456-7a.diff, FELIX-3456-8.diff, FELIX-3456-8a.diff, FELIX-3456-fmeschbe-6.patch, FELIX-3456-fmeschbe.patch
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Felix Meschberger updated FELIX-3456:
-------------------------------------
Fix Version/s: scr-1.6.2
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Fix For: scr-1.6.2
>
> Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff, FELIX-3456-5.diff, FELIX-3456-5a.diff, FELIX-3456-5b.diff, FELIX-3456-7.diff, FELIX-3456-7a.diff, FELIX-3456-fmeschbe-6.patch, FELIX-3456-fmeschbe.patch
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Felix Meschberger updated FELIX-3456:
-------------------------------------
Fix Version/s: (was: scr-1.8.0)
scr-1.6.2
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Assignee: David Jencks
> Priority: Critical
> Fix For: scr-1.6.2
>
> Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff, FELIX-3456-5a.diff, FELIX-3456-5b.diff, FELIX-3456-5.diff, FELIX-3456-7a.diff, FELIX-3456-7.diff, FELIX-3456-8a.diff, FELIX-3456-8.diff, FELIX-3456-fmeschbe-6.patch, FELIX-3456-fmeschbe.patch
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "David Jencks (Updated) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
David Jencks updated FELIX-3456:
--------------------------------
Attachment: FELIX-3456-4.diff
This uses the same idea as the previous patch but fully synchronizes the enable and disable methods and the service factory getService and ungetService methods.
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Attachments: FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13286524#comment-13286524 ]
Felix Meschberger commented on FELIX-3456:
------------------------------------------
> So, I implemented something I think will work where the java.util.concurrent
> reentrant lock is used if available and if not doug lea's unfair lock.
+1
> Basically the solution to 3317 is no longer relevant and we can simplify the code a bit more.
Right.
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff, FELIX-3456-5.diff, FELIX-3456-5a.diff, FELIX-3456-5b.diff, FELIX-3456-7.diff, FELIX-3456-7a.diff, FELIX-3456-fmeschbe-6.patch, FELIX-3456-fmeschbe.patch
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "Richard Ellis (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13252655#comment-13252655 ]
Richard Ellis commented on FELIX-3456:
--------------------------------------
If only my browser had refreshed faster I could have agreed with you already David instead of disagreeing with myself :)
I do agree David, my hasty attempt at a fix without a full understanding of the code is not correct.
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "David Jencks (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13253938#comment-13253938 ]
David Jencks commented on FELIX-3456:
-------------------------------------
Just in case anyone was wondering, as I was, I checked the spec and (4.3 section 5.3) all service events must be delivered synchronously. Thus there is definitely a possibility of deadlocks if we're not careful (more careful than my patch).
A colleague tried a completely asynchronous model for service events in scr and although start seemed to work, stopping resulted in a lot of work on stopped bundles and component objects. I think if we can convince ourselves that it conforms to the spec this is a viable approach but it will take quite a bit of work to identify all the cases where we're working with closed stuff.
I wonder to what extent we can remove the deadlock scenarios by
(a) avoiding the synchronized block entirely when possible. For instance the first place we found this, DependencyManager.serviceAdded, I think we can skip the block I synchronized if the dependency is not mandatory, because if its not mandatory it showing up can't result in service activation.
(b) avoiding calling out, such as the bind and unbind methods, from a synchronized block. This might be a wacky and non-plausible idea.... We might have an internal and external state. for instance:
thread 1 supplies service A
thread 1 gets the lock and updates internal and external state to "activating"
thread 2 supplies service B and can't get the lock
thread 1 does the calculations in Unsatisfied.activate up to the point where it calls out to the bind methods, and then updates the internal state to "active" and releases the lock
thread 2 gets the lock and sees the internal state is "active" so it doesn't do much except release the lock
thread 1 finishes calling the bind methods and updates the external state to "active".
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Attachments: FELIX-3456-1.diff
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (FELIX-3456) Component ignores required static
service addition when in Activating state
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FELIX-3456?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13278389#comment-13278389 ]
Felix Meschberger commented on FELIX-3456:
------------------------------------------
ComponentContext.enable and .disable must set the enabled and disabled state immediately but any action resulting from this must be asynchronous. The current implementation violates the spec in that the status is not immediately set. But the actual action occurrs asynchronously as mandated in section 112.5.1.
This is to my knowledge the only explicit notion of timing. Particularly there is no requirement to either activate or deactivate components synchronously or asynchronously on SCR or bundle startup or stop. Experience showed me that any attempt to make these asynchronous (remember we had them both asynchronous at one point in time) had issues.
Stopping components asynchronously on bundle or SCR shutdown or service unregistration causes problems (been there done that).
Starting components asynchronously causes non-deterministic startup behaviour while not being much more stable with respect to deadlocks.
So, I really don't want to change that.
If we need to fix something to make ComponentContext.enable and .disable more spec compliant (setting the state immediately while doing the action asynchronously), we can do so....
> Component ignores required static service addition when in Activating state
> ---------------------------------------------------------------------------
>
> Key: FELIX-3456
> URL: https://issues.apache.org/jira/browse/FELIX-3456
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.6.0
> Environment: Using org.apache.felix.scr svn rev 1298268 on Mac
> Reporter: Richard Ellis
> Priority: Critical
> Attachments: FELIX-3456-1.1.diff, FELIX-3456-1.diff, FELIX-3456-3.diff, FELIX-3456-4.diff, FELIX-3456-5.diff, FELIX-3456-5a.diff, FELIX-3456-5b.diff, FELIX-3456-fmeschbe.patch
>
>
> I have a component with two required static service references (A and B). In my scenario A and B are registered nearly simultaneously on different threads and this causes the DependencyManager to ignore the addition of one of these two services (B). This causes the component to remain unsatisfied and never activate, since the service that was ignored is not re-registered at any time and nothing subsequently causes the component to re-activate.
> This happens as follows:
> 12:30:59:317 Thread 1 - Registers Service B/257
> 12:30:59:320 Thread 2 - Registers Service A/258
> 12:30:59:320 Thread 2 - Dependency Manager: Adding Service A/258
> 12:30:59:321 Thread 2 - Dependency Manager: Service serviceA registered, activate component
> 12:30:59:321 Thread 2 - State transition : Unsatisfied -> Activating
> 12:30:59:321 Thread 2 - Activating component
> 12:30:59:321 Thread 1 - Dependency Manager: Adding Service B/257
> 12:30:59:321 Thread 2 - Dependency not satisfied: serviceB
> 12:30:59:321 Thread 1 - Dependency Manager: Added service serviceB is ignored for static reference <--- I believe we end up here because Thread 2 has moved the component from Unsatisfied to Activating and the reference is a static reference
> 12:30:59:321 Thread 2 - Not all dependencies satisified, cannot activate
> 12:30:59:321 Thread 2 - State transition : Activating -> Unsatisfied
> Because the addition of Service B has been ignored and serviceB is a required dependency my component then never activates even though my reqiured service is present.
> There is a comment in DependencyManager#serviceAdded method:
> // FELIX-1413: if the dependency is static and the component is
> // satisfied (active) added services are not considered until
> // the component is reactivated for other reasons.
> This suggests that the static service should only be ignored if the component is satisfied(active), which would be correct, but in this case the component is only activating (and will fail to activate because one of the two dependencies is not yet satisfied) and there is no check of state at this time.
> A simple fix would be to check the state of the component as well as if the service is static e.g.
> replace if ( m_dependencyMetadata.isStatic() )
> with if ( m_dependencyMetadata.isStatic() && m_componentManager.getState() == AbstractComponentManager.STATE_ACTIVE )
> This is an easy fix, but I guess may leave a small window where a static reference could get replaced while a component was still activating if another instance of the same service was registered on a different thread.
> There are other fixes that could be done by synchronizing more around service additions.
> Is anyone willing to make this fix or does anyone have any thoughts about this issue?
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira