doctrine / DoctrineMongoDBBundle

Integrates Doctrine MongoDB ODM with Symfony
http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html
MIT License
379 stars 230 forks source link

Production environment hydrator error #187

Closed priestor closed 11 years ago

priestor commented 11 years ago

Heyhey :),

I have a problem with the cache/enviroment, I'dont know exactly. The Situation:

I'm building an API with OAuth 2.0. It runs like charm, but! Then I was stresstesting it with ab.

ab -c 10 -n 1000 http://mysite.com/api/res

Whats strange is the following output (part):

[...] Complete requests: 121 Failed requests: 120 [...]

Its always about this +/- 10.

But why? In another terminal I was watching the apache error.log with tail -f. The following error code comes with the firs ab test:

PHP Fatal error: Class 'Hydrators\RessourceBundleDocumentRessourceHydrator' not found in /var/www/Ressources/Symfony/vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php on line 146

and then comes, now and then, this little fella along: (32)Broken pipe: core_output_filter: writing data to the network.

The thing is "RessourceBundleDocumentRessourceHydrator" is in the cache folder. Is this a bug? I posted it here because I think this is a problem with in the core? I was also thinking about file r/w issues.

Any help would be great! Thank you :)

stof commented 11 years ago

Have you generated the hydrators for the prod environment ? they are not auto-generated on each request (for performance) so you need to run the command first

priestor commented 11 years ago

If u mean the command-line method, yes! And I can see the files in the filesystem. I have no problem with the request by browser. It happens when I request the URL concurrent. :(

I also checked the returned path, no typo.

Baachi commented 11 years ago

Is apc installed?

priestor commented 11 years ago

Yes, it is. Checked also with $php app/check.php, no errors.

jmikola commented 11 years ago

This doesn't seem like a bundle problem. If anything, it reminds me of the Symfony issue from last year about autoloading classes sporadically missing. I don't believe that was ever resolved, but I can't seem to find it.

priestor commented 11 years ago

I'm also thinking that its more like a core problem, isn't it? Thats why i posted it in Symfony/Symfony in the first place.

:(

priestor commented 11 years ago

News from the front... I was checking the files and I saw that someone changed the allowd ips in the app_dev.php so the "ab stresstest" for the dev environment is also failing... it was running because the response was the "no access page"...

Puh, that sucks! That guided me in kind of the wrong direction. The problem still stands, but there is no difference between the PROD and DEV environment. Sorry!

Feeling kind of silly right now. :|

// Edited the title and content, so it doesnt confuse someone.

@jmikola: Found this issue: https://github.com/symfony/symfony/issues/3856

seems that the problem is still there?

priestor commented 11 years ago

I'm back on the track with APC and I'm testing around, currently I set "apc.stat=0" and changed the prefix for ApcClassLoader in the app.php to anotherone. Not 100% sure if this was the solution in my case, but it seems to fix the "file not found". But I don't trust it :o)!

Checking more tomorrow, maybe it helps someone else so far.

jmikola commented 11 years ago

@priestor: That was the issue I was thinking of. I'm going to close this out, as I don't think it's an ODM issue.

ghost commented 10 years ago

@stof is there any documentation for how to handle hydrators generation on dev and production? Can Apc cache be used to avoid manual generation of hydrators?

duraki commented 6 years ago

@daniphp a little bit late with response but for anyone else, hard remove the cache (with rm -rf) and regenerate new hydrator classes through command doctrine:mongodb:generate:hydrators.

mesanthu commented 3 years ago

We faced a similar issue, But our case is different Just mentioning here thinking it would help someone who has a project like ours, We had multiple kernels setup for the same project what we had done is had to clear our cache with Prod env individually for each kernel, We were removing the cache folder directly as an attempt to fix the issue, But turned out that removing the folder directly will cause some other issues. so clear cache with prod mode and see if that works.