BrandOriented / PimcoreCiHubConnector

This bundle adds full integration between Pimcore and CI-HUB Connector. Now you can add, delete and download all assets, lock and unlock, get all versions for specified asset and much more.
https://brandoriented.io/
Other
5 stars 6 forks source link

Memory leak #28

Closed birgerstoeckelmann closed 3 months ago

birgerstoeckelmann commented 4 months ago

Pimcore version(s) affected

11

Description

We have about 140k assets in the database. I am only allowed to create Ci Hub configurations as an administrator with all workspaces. If you now click on "Save" to save the Ci Hub configuration, the index is started. In the corresponding method, all assets seem to be indexed, and their parent folder elements are indexed. An enormous number of messages are placed in the queue for this purpose - we ran out of memory after over 240k entries in the table. We have also already increased the PHP memory to 3GB, which is only tolerable on the development system.

How to reproduce

The following method seems to overflow the working memory:

protected function initIndex(ConfigReader $configReader): void
    {
        $assets = $this->getDb()->executeQuery('SELECT id, parentId FROM assets')->fetchAllAssociative();
        foreach ($assets as $asset) {
            $name = $configReader->getName();

            if (!$configReader->isAssetIndexingEnabled()) {
                continue;
            }

            $this->messageBus->dispatch(new UpdateIndexElementMessage($asset['id'], 'asset', $name));
            $this->enqueueParentFolders(Asset::getById($asset['parentId']), Folder::class, 'asset', $name);
        }

        $objects = $this->getDb()->executeQuery('SELECT id, parentId FROM objects')->fetchAllAssociative();
        foreach ($objects as $object) {
            $name = $configReader->getName();

            if (!$configReader->isAssetIndexingEnabled()) {
                continue;
            }

            $this->messageBus->dispatch(new UpdateIndexElementMessage($object['id'], 'object', $name));
            $this->enqueueParentFolders(DataObject::getById($object['parentId']), DataObject\Folder::class, 'object', $name);
        }
    }
labudzinski commented 4 months ago

Thank you for the notification, indeed this is an issue that we are currently working on.