Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-3721

Configuration not always provided upon initial service registration




      With the changes to implement Targeted PIDs and refactoring of the service trackers for FELIX-3577 and FELIX-3481 a race condition has been introduced which may cause ManagedService and ManagedServiceFactory services to not be called back on initial registration.

      This has been exhibited by test build of the yet unpublished OSGi CT for Configuration Admin, for example:
      (1) ManagedService PID 1 registered
      (2) ManagedService PID 2 registered
      (3) ManagedService PID 2 called back

      The problem is, that before the call back to ManagedService PID 2, the call back to ManagedService PID 1 is expected.

      Turns out that this race condition takes place, which may primarily be reproduced on Linux platforms, probably due to different threading implementations on the platform:

      T1: register service
      T1: call ServiceTracker.addingService
      T1: schedule service update task
      T2: run update task
      T2: terminate update task without calling the service
      T1: return from ServiceTracker.addingService returning ConfigurationMap

      This is expected since the service update task in T2 expects the ConfigurationMap stored in the ServiceTracker. But this is not the case yet because the ServiceTracker.addingService method has not yet returned it for it to be stored in the ServiceTracker. Therefore T2 is not able to call back the service and thus the update call never takes place.

      The fix is either to delay the task execution in T2 or to prepare the ConfigurationMap in T1 and hand it over to the task to be executed in T2. The first solution is suboptimal because we cannot find a timing value which (a) does not delay too much bug (b) still makes sure the ConfigurationMap will ultimately be available.


        Issue Links



              fmeschbe Felix Meschberger
              fmeschbe Felix Meschberger
              0 Vote for this issue
              1 Start watching this issue