data-importer icon indicating copy to clipboard operation
data-importer copied to clipboard

[Bug]: The "kernel" service is synthetic error when processing parallel

Open IronSean opened this issue 1 year ago • 14 comments

Expected behavior

datahub:data-importer:process-queue-parallel will properly process rows, or throw errors when there is a logic error

Actual behavior

Occasionally rows fail with the following error: Error processing element: IMPORT,DATA,HERE The "kernel" service is synthetic, it needs to be set at boot time before it can be used.

This seems like a possible race condition as it seems to happen more when the server is under load by other tasks, but I might be imagining that.

Steps to reproduce

Inconsistent. Run lots of 10k, 100k, 1m row datahub imports with multiple parallel workers (8 in my case on 4 cores) while the server is under other workloads.

Sometimes there is no error, sometimes a few rows, and sometimes the whole import fails.

IronSean avatar Aug 15 '24 19:08 IronSean

Thanks a lot for reporting the issue. We did not consider the issue as "Pimcore:Priority", "Pimcore:ToDo" or "Pimcore:Backlog", so we're not going to work on that anytime soon. Please create a pull request to fix the issue if this is a bug report. We'll then review it as quickly as possible. If you're interested in contributing a feature, please contact us first here before creating a pull request. We'll then decide whether we'd accept it or not. Thanks for your understanding.

github-actions[bot] avatar Sep 05 '24 07:09 github-actions[bot]

I have the same issue. image

abdelrhmanyosry avatar Sep 17 '24 15:09 abdelrhmanyosry

Hi everyone,

is there something new in this? I also occur this error since a few days?

stephangmms avatar Nov 07 '24 14:11 stephangmms

we are not able to reproduce it, see also thread here, which is a similar topic. any additional insights or debugging results are welcome.

fashxp avatar Nov 07 '24 14:11 fashxp

@stephangmms it's happening when importing a large number of products with a large number of attributes we had more than 200+ attributes for each product.

abdelrhmanyosry avatar Nov 07 '24 15:11 abdelrhmanyosry

@stephangmms it's happening when importing a large number of products with a large number of attributes we had more than 200+ attributes for each product.

that sounds familiar. Sadly i have not too much insight into that problem because i was out of this project for a while. I only know that the data-importer jobs (csv-imports, parallel execution) run in small scale test (<100 items) perfectly. Now as we are testing 5000+ products with only 3 attributes/product this problems occur.

[DATA-IMPORTER] Error processing element: 0695, --- DATA REMOVED FOR PRIVACY REASONS --- , Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: The "kernel" service is synthetic, it needs to be set at boot time before it can be used. in /var/www/html/vendor/symfony/dependency-injection/Container.php:246

Pimcore: 11.3.0 DataHub: 1.7.2 Data-Importer: 1.9.0

stephangmms avatar Nov 07 '24 15:11 stephangmms

I'm able to reproduce this with two bundles

  1. Data hub importer
  2. Data quality management

Stacktrace:

prod-error.log:3325:[2025-03-20T03:00:14.499398+00:00] DATA-IMPORTER.ERROR: Error processing element: Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: The "kernel" service is synthetic, it needs to be set at boot time before it can be used. in /var/www/pimcore11/vendor/symfony/dependency-injection/Container.php:246 Stack trace: 
#0 /var/www/pimcore11/vendor/symfony/dependency-injection/Container.php(211): Symfony\Component\DependencyInjection\Container::make() 
#1 /var/www/pimcore11/var/cache/prod/ContainerNOPK04J/getInstaller10Service.php(36): Symfony\Component\DependencyInjection\Container->get() 
#2 /var/www/pimcore11/var/cache/prod/ContainerNOPK04J/App_KernelProdContainer.php(896): ContainerNOPK04J\getInstaller10Service::do() 
#3 /var/www/pimcore11/var/cache/prod/ContainerNOPK04J/getDataQualitySubscriberService.php(28): ContainerNOPK04J\App_KernelProdContainer->load() 
#4 /var/www/pimcore11/var/cache/prod/ContainerNOPK04J/App_KernelProdContainer.php(896): ContainerNOPK04J\getDataQualitySubscriberService::do() 
#5 /var/www/pimcore11/var/cache/prod/ContainerNOPK04J/App_KernelProdContainer.php(1732): ContainerNOPK04J\App_KernelProdContainer->load() 
#6 /var/www/pimcore11/vendor/symfony/event-dispatcher/EventDispatcher.php(257): ContainerNOPK04J\App_KernelProdContainer::ContainerNOPK04J\{closure}() 
#7 /var/www/pimcore11/vendor/symfony/event-dispatcher/EventDispatcher.php(220): Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}() 
#8 /var/www/pimcore11/vendor/symfony/event-dispatcher/EventDispatcher.php(56): Symfony\Component\EventDispatcher\EventDispatcher->callListeners() 
#9 /var/www/pimcore11/vendor/pimcore/pimcore/models/DataObject/Concrete.php(173): Symfony\Component\EventDispatcher\EventDispatcher->dispatch() 
#10 /var/www/pimcore11/vendor/pimcore/pimcore/models/DataObject/AbstractObject.php(552): Pimcore\Model\DataObject\Concrete->update() 
#11 /var/www/pimcore11/vendor/pimcore/pimcore/models/DataObject/Concrete.php(637): Pimcore\Model\DataObject\AbstractObject->save() 
#12 /var/www/pimcore11/vendor/pimcore/data-importer/src/Processing/ImportProcessingService.php(234): Pimcore\Model\DataObject\Concrete->save() 
#13 /var/www/pimcore11/vendor/pimcore/data-importer/src/Processing/ImportProcessingService.php(148): Pimcore\Bundle\DataImporterBundle\Processing\ImportProcessingService->processElement() 
#14 /var/www/pimcore11/vendor/pimcore/data-importer/src/Command/ParallelProcessQueueCommand.php(70): Pimcore\Bundle\DataImporterBundle\Processing\ImportProcessingService->processQueueItem() 
#15 /var/www/pimcore11/vendor/webmozarts/console-parallelization/src/ParallelExecutor.php(250): Pimcore\Bundle\DataImporterBundle\Command\ParallelProcessQueueCommand->runSingleCommand() 
#16 /var/www/pimcore11/vendor/webmozarts/console-parallelization/src/ParallelExecutor.php(229): Webmozarts\Console\Parallelization\ParallelExecutor->runTolerantSingleCommand() 
#17 /var/www/pimcore11/vendor/webmozarts/console-parallelization/src/ParallelExecutor.php(202): Webmozarts\Console\Parallelization\ParallelExecutor->processItems() 
#18 /var/www/pimcore11/vendor/webmozarts/console-parallelization/src/ParallelExecutor.php(85): Webmozarts\Console\Parallelization\ParallelExecutor->executeChildProcess() 
#19 /var/www/pimcore11/vendor/webmozarts/console-parallelization/src/Parallelization.php(142): Webmozarts\Console\Parallelization\ParallelExecutor->execute() 
#20 /var/www/pimcore11/vendor/symfony/console/Command/Command.php(326): Pimcore\Bundle\DataImporterBundle\Command\ParallelizationAbstractCommand->execute() 
#21 /var/www/pimcore11/vendor/symfony/console/Application.php(1096): Symfony\Component\Console\Command\Command->run() 
#22 /var/www/pimcore11/vendor/symfony/framework-bundle/Console/Application.php(126): Symfony\Component\Console\Application->doRunCommand() 
#23 /var/www/pimcore11/vendor/symfony/console/Application.php(324): Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() 
#24 /var/www/pimcore11/vendor/symfony/framework-bundle/Console/Application.php(80): Symfony\Component\Console\Application->doRun() 
#25 /var/www/pimcore11/vendor/symfony/console/Application.php(175): Symfony\Bundle\FrameworkBundle\Console\Application->doRun() 
#26 /var/www/pimcore11/bin/console(49): Symfony\Component\Console\Application->run() 

It seems like there is a listener on save object from data quality mangment which tries to create Installer.php service but fails for the second argument Bundle interface. As when it compiles it tries to get bundle from the kernel $container->get('kernel'))->getBundle("PimcoreDataQualityManagementBundle")

Compiled installer code:

  GNU nano 6.2                                                                                                                        /var/www/pimcore11/var/cache/prod/ContainerNOPK04J/getInstaller10Service.php                                                                                                                                 
<?php

namespace ContainerNOPK04J;

use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;

/*
 * @internal This class has been auto-generated by the Symfony Dependency Injection Component.
 */
class getInstaller10Service extends App_KernelProdContainer
{
    /*
     * Gets the public 'Pimcore\Bundle\DataQualityManagementBundle\Installer' shared autowired service.
     *
     * @return \Pimcore\Bundle\DataQualityManagementBundle\Installer
     */
    public static function do($container, $lazyLoad = true)
    {
        include_once \dirname(__DIR__, 4).'/vendor/pimcore/pimcore/lib/Extension/Bundle/Installer/InstallerInterface.php';
        include_once \dirname(__DIR__, 4).'/vendor/pimcore/pimcore/lib/Extension/Bundle/Installer/AbstractInstaller.php';
        include_once \dirname(__DIR__, 4).'/vendor/pimcore/pimcore/lib/Extension/Bundle/Installer/SettingsStoreAwareInstaller.php';
        include_once \dirname(__DIR__, 4).'/vendor/pimcore/data-quality-management-bundle/src/Installer.php';
        include_once \dirname(__DIR__, 4).'/vendor/doctrine/migrations/src/MigrationsRepository.php';
        include_once \dirname(__DIR__, 4).'/vendor/pimcore/pimcore/lib/Migrations/FilteredMigrationsRepository.php';
        include_once \dirname(__DIR__, 4).'/vendor/doctrine/migrations/src/Metadata/Storage/MetadataStorage.php';
        include_once \dirname(__DIR__, 4).'/vendor/pimcore/pimcore/lib/Migrations/FilteredTableMetadataStorage.php';

        $a = ($container->services['doctrine.dbal.default_connection'] ?? self::getDoctrine_Dbal_DefaultConnectionService($container));

        if (isset($container->services['Pimcore\\Bundle\\DataQualityManagementBundle\\Installer'])) {
            return $container->services['Pimcore\\Bundle\\DataQualityManagementBundle\\Installer'];
        }

        $container->services['Pimcore\\Bundle\\DataQualityManagementBundle\\Installer'] = $instance = new \Pimcore\Bundle\DataQualityManagementBundle\Installer($a, ($container->services['kernel'] ?? $container->get('kernel'))->getBundle("PimcoreDataQualityManagementBundle"), [($container->services['Pimcore\\Bundle\\ApplicationLoggerBund>

        $instance->setMigrationRepository(($container->services['Pimcore\\Migrations\\FilteredMigrationsRepository'] ??= new \Pimcore\Migrations\FilteredMigrationsRepository()));
        $instance->setTableMetadataStorage(($container->services['Pimcore\\Migrations\\FilteredTableMetadataStorage'] ??= new \Pimcore\Migrations\FilteredTableMetadataStorage()));
        $instance->setDependencyFactory(($container->privates['doctrine.migrations.dependency_factory'] ?? $container->load('getDoctrine_Migrations_DependencyFactoryService')));

        return $instance;
    }
}

cuca24 avatar Mar 20 '25 13:03 cuca24

thx for the additional findings. how does your Pimcore setup exactly look like? which bundles have you installed? in which order are they activated in bundles.php?

fashxp avatar Mar 20 '25 15:03 fashxp

I have the same issue

Image

This seems like a possible race condition as it seems to happen more when the server is under load by other tasks, but I might be imagining that.

yeah same case with me

MohamedBeshir-SW avatar Mar 20 '25 18:03 MohamedBeshir-SW

For people reporting the '"kernel" service is synthetic' error, are you using the Command or Symfony Messenger based Importer?

cancan101 avatar Mar 25 '25 02:03 cancan101

@cancan101

I am using the Command-based, and have a cron job on the server for executing this command every 5 minutes bin/console datahub:data-importer:process-queue-parallel

MohamedBeshir-SW avatar Mar 25 '25 03:03 MohamedBeshir-SW

when you do symfony messenger based imports this problem doesn't appear?

fashxp avatar Mar 25 '25 08:03 fashxp

This might be the upstream / root issue: https://github.com/webmozarts/console-parallelization/issues/294

@fashxp when we used the symfony messenger approach, we did not see the error; however, the import never finished. It got stuck most of the way complete. I am not 100% sure where to look for the kernel errors (did not see in the prod.err, application logger or the supervisord log).

Update Our root issue was an encoding issue in the CSV file. The encoding issue caused the sequential importer and symfony messenger to hang and triggered the kernel error in the parallel command importer.

cancan101 avatar Mar 25 '25 13:03 cancan101

related https://github.com/pimcore/data-importer/issues/466

fashxp avatar Apr 03 '25 14:04 fashxp

see https://github.com/orgs/pimcore/discussions/18412

fashxp avatar May 13 '25 11:05 fashxp

could you guys please double check if https://github.com/pimcore/pimcore/pull/18413 fixes the issue for you as well? thx very much!

fashxp avatar May 19 '25 06:05 fashxp

Closing for now, since https://github.com/pimcore/pimcore/pull/18413 in pimcore/pimcore:12.0.1 probably fixes this. If not, please come back...

fashxp avatar Jun 16 '25 06:06 fashxp