You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Pawe�� Boguski (Jira)" <ji...@apache.org> on 2023/01/13 13:31:00 UTC

[jira] [Created] (SLING-11754) Race condition in OsgiInstaller

Pawe�� Boguski created SLING-11754:
--------------------------------------

             Summary: Race condition in OsgiInstaller
                 Key: SLING-11754
                 URL: https://issues.apache.org/jira/browse/SLING-11754
             Project: Sling
          Issue Type: Bug
          Components: Installer
    Affects Versions: Installer Core 3.12.0, Installer Packages Factory 1.0.4
            Reporter: Pawe�� Boguski


[OsgiInstallerImpl|https://github.com/apache/sling-org-apache-sling-installer-core/blob/master/src/main/java/org/apache/sling/installer/core/impl/OsgiInstallerImpl.java#L143] is using [SortingServiceTracker|https://github.com/apache/sling-org-apache-sling-installer-core/blob/master/src/main/java/org/apache/sling/installer/core/impl/SortingServiceTracker.java#L87] to schedule a retry of the OSGi installer run when new service of type ResourceTransformer is added. During the OSGi installer run, the list of available ResourceTransformer services is loaded to [transform resources|https://github.com/apache/sling-org-apache-sling-installer-core/blob/master/src/main/java/org/apache/sling/installer/core/impl/OsgiInstallerImpl.java#L953].  

It might happen that the list of available ResourceTransformer services will be loaded during transforming resources before the new ResourceTransformer which triggered the OSGi installer run will be available in the SortingServiceTracker instance, because the scheduleRetry call is done in SortingServiceTracker.addingService not when the service is already available in SortingServiceTracker but during the preparation of the service instance (the instance returned from SortingServiceTracker.addingService is later added to services list in SortingServiceTracker).

So in other words, there is a race condition between adding a new service instance to SortingServiceTracker services list and OSGi installer run which perform getting the instances of ResourceTransformer services from the SortingServiceTracker.

In the result activation of ResourceTransformer might trigger the OSGi installer run but the service will not be found during the run.

Example issue caused by this:

If such a last OSGi installer run would be caused by activation of [PackageTransformer|https://github.com/apache/sling-org-apache-sling-installer-core/blob/master/src/main/java/org/apache/sling/installer/core/impl/OsgiInstallerImpl.java#L953] the untransformed content packages (for example added by OSGI feature model during the first start of the instance) stays untransformed.

In our pipelines for PRs validation this is happening very often.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)