Skip to content

Deadlock using ConfigAdmin? #114

@svidoso

Description

@svidoso

Hi,

I have implemented a custom ConfigAdminPersistence which uses a database.
When i use this, the application gets stuck in updated:

@ComponentFactory("any_factory")
@Provides("any")
@Property("_name", "name", "asd")
@Instantiate("anyinstance")
@Provides(pelix.services.SERVICE_CONFIGADMIN_MANAGED)
@Property("_service_pid", "service.pid", "any_pid")
class AnyService(object):  

    def updated(self, props):
        logger.debug(f"updating {self._name=}, {props=}")
        # self._name = props.get("name")
        self._name = "None" #  <-- gets stuck here
        logger.debug("updated") 

I am wondering if anyone has an idea what is going wrong here. Somehow just changing the value of a Property will produce a deadlock. I don't see how the custom ConfigAdminPersistence could be involved here.

Nevertheless below the ConfigAdminPersistence:

@ComponentFactory("configadmin-persistence-mongodb-factory")
@Provides(
    [
        services.SERVICE_CONFIGADMIN_PERSISTENCE
    ]
)
@Requires("_db_service", "db_service")
@Property("_collection_name", "collection_name", CollectionName.ConfigAdminPersistence.value)
class ConfigAdminPersistence(object):
    PID_KEY = "service_pid"

    def exists(self, pid):
        return self._db_service.find_one(self._collection_name,
                                         filter={ConfigAdminPersistence.PID_KEY: pid}) is not None

    def load(self, pid):
        return self._db_service.find_one(self._collection_name, filter={ConfigAdminPersistence.PID_KEY: pid},
                                         projection={'_id': 0})

    def store(self, pid, properties):
        if 'service.pid' in properties:  # mongodb cannot cope with dot in key
            del properties['service.pid']

        return self._db_service.replace_one(self._collection_name,
                                            filter={ConfigAdminPersistence.PID_KEY: pid},
                                            doc={**properties, ConfigAdminPersistence.PID_KEY: pid},
                                            upsert=True)

    def delete(self, pid):
        return self._db_service.delete_one(self._collection_name,
                                           filter={ConfigAdminPersistence.PID_KEY: pid})

    def get_pids(self):
        pids = set(self._db_service.find(self._collection_name).distinct(ConfigAdminPersistence.PID_KEY))

        return pids

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions