mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Many weird characters in metadata and generated sql queries #5749
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @pylebecq on GitHub (Oct 24, 2017).
Hello guys,
I'm opening an issue because I have on my production servers many issues and I don't know if they are related or not, I don't really know if the issue is coming to from the ORM or the DBAL, and I really can't figure things out, so maybe you guys will have any hint that may help me, or maybe you will be able to point me to another issue I did not find using the search engine that talk about the same kind of issue.
Below you will find many errors that are reported by New Relic with the stack trace (sorry, it will be a long post), and I will explain what I notice. I just can't figure the root cause out. There is one thing for you to know: there are no typo in our code. The issues only appear after some hours, not immediately to add a little more weird to the story.
I'm using Doctrine ORM 2.5.10 inside a Symfony 2.8.27 project, using doctrine bundle 1.6.8. We're running php 7.0.20, and using apcu as a metadata/query/result cache.
In this one we can see that the class name is wrong, it contains a [ instead of a \: Mdm\Bundle[ProductBundle\Entity\Shop vs Mdm\Bundle\ProductBundle\Entity\Shop
Here we can see in the SQL query, in the SELECT clause, a reference to f1_-lang instead of f1_.lang
Here, there is a small weird square just before
f1_.idcorresponding to a non printable character it seems.Looks like first example, but the stack trace is not the same. It is still an error in a class name: AppBuncle\Entity\CategoryNewProduct instead of AppBundle\Entity\CategoryNewProduct. This example is very widespread, and it is the same thing every time: a character is replaced by another one, and everytime it is the same pattern: it is replaced by the previous character in the ascii table. In this example, the letter d is replaced by c, I have examples of a ReflectionException concerning a property dmail that does not exist intead of email. If we look the first example, [ is actually preceding \ in the ascii table. I also have another example, still matching the pattern: Mdm\Bundle\C`tegoryBundle\Repository instead of Mdm\Bundle\CategoryBundle\Repository
I don't even know what to think of this one. We can see in the select clause there is s0_.market @S market_2 instead of s0_.market AS market_2
This one is also very weird, the table name used in the FROM clause is the alias instead of the real table name.
This is it. Any help will be greatly appreciated, any hint or anything. Again, I don't know if this is a bug from doctrine or something else but maybe you guys will be able to clarify this. Unfortunately, since the issues come over time, I cannot give you a git repository with some code to reproduce this.
Best regards,
@Ocramius commented on GitHub (Oct 24, 2017):
Possibly one of the issues here.
This bit looks interesting: is it a simple service lookup? What is being passed to
EntityManager#getRepository()?@pylebecq commented on GitHub (Oct 26, 2017):
Hello @Ocramius ,
Thank you for taking some time to review all of this.
In the appProdProjectContainer.php at line 3072 there is this method:
And the
$this->get('mdm.shop.repository')results to a call to this other method in the appProdProjectContainer:About APCu, for now we are trying to reduce its usage by removing the result cache from it, it seems the servers are becoming more stable. I opened an issue because I wanted to find the root cause to make sure we won't run into it again in the future.
@Majkl578 commented on GitHub (Dec 19, 2017):
There is no error in the container code provided, entity class' name is ok as well.
In third error log, it would be interesting what the square sign is, but I don't think it would significantly help (unless it's \x00, APC used to have problem with nulls).
In last error log the table name is completely missing.
This doesn't look like something ORM itself would cause, I would definitely blame APCu or other middleware. As far as I know APCu doesn't use any locking mechanism and doesn't have any sort of transactions, couldn't this be caused by high load & number of writes? But anyway, I'd suggest to switch to different storage, i.e. Redis.
@pylebecq commented on GitHub (Dec 20, 2017):
Yes, it seems APCu is the one to blame here. We switched the result cache to redis, it's working fine now. Metadata and Query cache are still using APCu.
I don't really know what happens to be honest. There is a lot to read about APCu cache fragmentation, I don't know if it takes part in this issue or not but for now we have removed all usage of TTL with APCu and the issue does no happen anymore. It seems like add/removal of cache entries "corrupts" other entries eventually.
Thank you guys for taking time reading my long original post and giving me a few hints and places to look for.