Felix
  1. Felix
  2. FELIX-3039

SCR cleans up delayed service components too aggressively

    Details

      Description

      In the case of an ordinary delayed service component, SCR immediately deactivates and destroys the component when its service is released by the consumer. In cases where a consumer occasionally binds and invokes the service (e.g. EventAdmin) this can cause the component to be continuously destroyed and recreated.

      Note that Equinox's DS offers a little more control, we can choose either to immediately clean up or never clean up (and the default is never). This is still not very satisfactory though.

      I think ideally there should be a configurable timeout, so that a component will be cleaned up only if it is not used for some time. I also think the default should be quite long, e.g. many minutes.

        Activity

        Felix Meschberger made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Hide
        Felix Meschberger added a comment -

        Close after release

        Show
        Felix Meschberger added a comment - Close after release
        Felix Meschberger made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Felix Meschberger [ fmeschbe ]
        Fix Version/s scr-1.6.2 [ 12315248 ]
        Resolution Fixed [ 1 ]
        Hide
        Felix Meschberger added a comment -

        In Rev. 1185082: Added new ds.delayed.keepInstances configuration property which allows to prevent delayed components from being clean up. By default this property is false (to implement the spec suggestion). The property can be set as a framework property or as part of the org.apache.felix.scr.ScrService configuration.

        Also updated documentation at http://felix.apache.org/site/apache-felix-service-component-runtime.html#ApacheFelixServiceComponentRuntime-Configuration

        Show
        Felix Meschberger added a comment - In Rev. 1185082: Added new ds.delayed.keepInstances configuration property which allows to prevent delayed components from being clean up. By default this property is false (to implement the spec suggestion). The property can be set as a framework property or as part of the org.apache.felix.scr.ScrService configuration. Also updated documentation at http://felix.apache.org/site/apache-felix-service-component-runtime.html#ApacheFelixServiceComponentRuntime-Configuration
        Hide
        Felix Meschberger added a comment -

        Actually the specification states that delayed components have to be deactivated and destroyed if not used any longer:

        If the service registered by a component configuration becomes unused
        because there are no more bundles using it, then SCR should deactivate
        that component configuration. This allows SCR implementations to eagerly
        reclaim activated component configurations. (112.5.4, Delayed Components)

        While "should" of course is not a requirement, I understand it as a strong recommendation. On the other hand, since this still allows the implementation to keep the components alive, it might make sense to keep them alive.

        Will consider an option "ds.dontDisposeInstances" as follows:

        • default: false – to implement the spec recommendation
        • base (static) configuration by framework property (BundleContext.getProperty)
        • dynamic configuration through Configuration Admin (if available)
        Show
        Felix Meschberger added a comment - Actually the specification states that delayed components have to be deactivated and destroyed if not used any longer: If the service registered by a component configuration becomes unused because there are no more bundles using it, then SCR should deactivate that component configuration. This allows SCR implementations to eagerly reclaim activated component configurations. (112.5.4, Delayed Components) While "should" of course is not a requirement, I understand it as a strong recommendation. On the other hand, since this still allows the implementation to keep the components alive, it might make sense to keep them alive. Will consider an option "ds.dontDisposeInstances" as follows: default: false – to implement the spec recommendation base (static) configuration by framework property (BundleContext.getProperty) dynamic configuration through Configuration Admin (if available)
        Hide
        Neil Bartlett added a comment -

        Not in a generic way because the spec does not state any such parameter name. Equinox uses a system property "equinox.scr.dontDisposeInstances" (http://wiki.eclipse.org/Equinox/RuntimeOptions) which can be true or false (default is true).

        Show
        Neil Bartlett added a comment - Not in a generic way because the spec does not state any such parameter name. Equinox uses a system property "equinox.scr.dontDisposeInstances" ( http://wiki.eclipse.org/Equinox/RuntimeOptions ) which can be true or false (default is true).
        Hide
        Andrei Pozolotin added a comment -

        good feature; is there any way to provide this config parameter in osgi-generic way?

        Show
        Andrei Pozolotin added a comment - good feature; is there any way to provide this config parameter in osgi-generic way?
        Hide
        Neil Bartlett added a comment -

        Correction, this should be a feature request, not a bug. The spec does not require either behaviour, implementations can clean up at their discretion.

        Show
        Neil Bartlett added a comment - Correction, this should be a feature request, not a bug. The spec does not require either behaviour, implementations can clean up at their discretion.
        Neil Bartlett created issue -

          People

          • Assignee:
            Felix Meschberger
            Reporter:
            Neil Bartlett
          • Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development