-
-
Notifications
You must be signed in to change notification settings - Fork 454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DoctrineMetadataCacheWarmer must load metadata first, check priority of you warmers when updated from 2.2.4 -> 2.3.0 #1310
Comments
I cannot reproduce this on any of my projects. I also tested it on Can you provide a reproducer @ivanbogomoloff ? |
No, i can't. It's magically gone. |
I have the same issue on cache:clear, doctrine:migrations:migrate and any other. |
With DoctrineBundle 2.3.0 we introduced a new and faster caching mechanism for the Doctrine meta data. For this to work properly we have to ensure that Are you able to create a reproducer? Happy to take a look then |
I'm facing the issue as well. In my project it has relation to "msgphp/msgphp" package. In my understanding problematic is the change of warmers priority introduced in #1260 - other packages may be bitten as well if they depend on specific priority value. |
we did not change any priority of cache warmers 😉 We introduced a new Again: if someone can provide a reproducer I can re-open this and take a look. |
I have created a reproducer, but I think it is related with the library Im using (it processes/loads entity metadata and should probably be run before doctrine warmup step which is not true anymore as new warmer has priority 1000, while msgphp one only 100). https://github.com/jkabat/doctrine-bundle-test bin/console cache:clear --env=prod --no-debug # http://prntscr.com/10zwd8u In my application setup I had better insight with cache:warmup command: http://prntscr.com/10zwfkn. Unfortunately in reproducer I do not see this kind of error. |
Reproducer doesn't work for me
|
I have the same issue. Unfortunately the project is private so I can't share it. I also, up to this point, failed to reproduce the behaviour in a new project. But after hours of debugging I can already give some insight why this is happening. In my project I have several connections/entity manager and therefore multiple cache warmer are registered all with priority 1000. For simplicity let's say we have the connections Now when I clear the cache the following happens: Iteration 1 (em_a)In
The event manager of Iteration 2 (em_b)Now the cache warmer of entity manager I will continue my quest to provide an example so you can debug it yourself but I hope I have already clearly outlined the cause for the bug. |
@TimWerdin this sounds indeed like it could be the issue... But then creating a reproducer should be possible when simply following your comments? |
I guess it will not take too much time to be able to produce a demo but I'm currently busy with testing and deploying a big project. I will continue my work next Thuesday |
I was a little bit busy last week but now I could prepare a demo application which shows the cause of the bug. You can find it here: https://github.com/TimWerdin/doctrine-bug-demo |
The reproducer looks good to me. Thanks @TimWerdin |
Is there any progress on this issue? This is limiting us to use older versions of doctrine to prevent conflicts |
Did not have much time recently. You could test #1378 and give some feedback there |
Anybody has a workaround for this? I cannot downgrade to 2.2.4 because of another issue in that version which was solved on 2.3. |
Hi all- just adding some info, I am experiencing this error on doctrine-bundle v2.5.5. Does anyone have a workaround? |
A workaround is to define a cache pool for the metadata yourself. See the older version of the recipe for example. |
note to me: make sure that the metadata cache key applies to all managers in the config (to apply the workaround) I had one manager triggering the autoloading of a repo in the other manager as well |
Hi @dmaicher, could you explain a bit more in detail how the workaround works? I have the same config in the |
which version of DoctrineBundle are you using? latest? If you configure your own psr6 metadata cache then the |
Lin is currently on vacation so I will continue the conversation for him.
and our
Sorry if I still don't get it but what exactly do I have to do? |
@TimWerdin so then you are only configuring the cache in |
We are not aware that we need to configure a cache per connection/entity_manager or that this is even possible. At least I can't find anything in the documentation |
I have the same error message when i am execute |
I have fixed it. In
when@prod:
doctrine:
orm:
auto_generate_proxy_classes: false
query_cache_driver:
type: pool
pool: doctrine.system_cache_pool
result_cache_driver:
type: pool
pool: doctrine.result_cache_pool
when@prod:
doctrine:
orm:
auto_generate_proxy_classes: false
metadata_cache_driver:
type: pool
pool: doctrine.system_cache_pool
query_cache_driver:
type: pool
pool: doctrine.system_cache_pool
result_cache_driver:
type: pool
pool: doctrine.result_cache_pool Just add : metadata_cache_driver:
type: pool
pool: doctrine.system_cache_pool |
I've encountered the same issue in tests:
This results in the cache warmer being added twice during autoconfiguration:
The workaround above works because the cache warmer is only added if no metadata_cache_driver is defined. |
Remove APP_DEBUG=0 in .env file |
i don't encountered this issue in version ^2.7 , so i decided to close issue |
I'm commenting in case anyone encounters this specific error through a Google search. (Sorry in advance if this comment re-opens the issue.) In my case, the error was caused by me initializing something in a service constructor that queries the database. Example: <?php
namespace App\Service;
class MyService
{
private $data;
private OtherService $otherService;
public function __construct(OtherService $otherService)
{
$this->otherService = $otherService;
$this->data = $otherService->queryForData();
}
} My solution was to initialize private $dataInit = false;
private function initData(): void
{
if ($this->dataInit) {
return;
}
$this->dataInit = true;
$this->data = $otherService->queryForData();
} Then I could call In hindsight, I should have took this approach regardless of any error. Especially in a Dependency Injection framework like Symfony. |
Hello all.
I got this message when run
bin/console cache:clear
orbin/console cache:warmup
.Conditions:
I have symfony 5.2.4 project out box
Then i run
composer update
doctrine-bundle updated to 2.2.4 -> 2.3.0.Then i got error.
DoctrineMetadataCacheWarmer must load metadata first, check priority of you warmers
The text was updated successfully, but these errors were encountered: