Details
-
Bug
-
Resolution: Unresolved
-
Critical
-
3.3.38, 4.6.8
-
None
-
None
-
Yes
Description
When Ibexa DXP is configured to use Redis for persistence cache, simultaneous updates can break content's cache rendering it inaccessible until the Redis cache is cleared.
Steps to reproduce
1. Clean installation of Ibexa DXP 3.3/4.6 with Redis as persistence cache (idealy, Redis and Ibexa DXP shouldn't be on the same machine to add some network latency)
2. Go to the back office and edit the main Landing page (ContentId 52). Add a code block with about 2MB of data (it seems that big content is more likely to break). You can use this page to generate the data https://onlinefiletools.com/generate-random-text-file. Publish the Landing Page after the block is added.
3. Create this command:
<?php namespace App\Command; use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Core\Repository\Repository; use Ibexa\Core\FieldType\TextLine\Value; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class CacheTestCommand extends Command { protected static $defaultName = 'app:ct'; public function __construct( private readonly Repository $repository, private readonly ContentService $contentService ) { parent::__construct(); } protected function execute(InputInterface $input, OutputInterface $output): int { $output->writeln('Updating LP...'); $this->repository->sudo(function () use ($output) { $lpContent = $this->contentService->loadContent(52); while (true) { $draft = $this->contentService->createContentDraft($lpContent->contentInfo); $updateStruct = $this->contentService->newContentUpdateStruct(); $updateStruct->setField('name', new Value('Ibexa Platform ' . rand(1,10000))); $updatedDraft = $this->contentService->updateContent($draft->versionInfo, $updateStruct); $lpContent = $this->contentService->publishVersion($updatedDraft->versionInfo); $output->write('.'); } }); $output->writeln('Done.'); return Command::SUCCESS; } }
4. Open the project in a shell in two different windows. In both, execute the previously created command: php bin/console app:ct
Results
After a moment, one of the commands will break with an exception being thrown:
Argument '$contentId' has a bad state: Someone just published another version of Content item 52
Or
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '242-31' for key 'PRIMARY'
Opening the page in a browser will result in an exception:
An exception has been thrown during the rendering of a template ("The User does not have the 'versionread' 'content' permission with: contentId '52', versionNo '32'").
To fix the error on the frontend, the persistence cache must be cleared:
php bin/console cache:pool:clear cache.redis
Expected result
Commands continue to execute without issues.