This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » General discussion » Sporadic ERROR: Unable to read cache file  (5) 1 Vote(s)
icon8.gif  Sporadic ERROR: Unable to read cache file [message #72507] Sun, 15 February 2009 16:07 Go to next message
colnector
Messages: 162
Registered: July 2008
Senior Member
Recently, I have begun to sporadically see the following error messages in my error log:

Unable to read cache file "/cache/frontend/prod/config/routing/symfony.routing.data.cache".

Obviously, this file can be read since otherwise the entire site wouldn't work. What could be the reasons for this error? Is symphony sometimes trying to update it?

Thanks

[Updated on: Sun, 15 February 2009 16:09]


Colnect Collectors Club Community
http://colnect.com

http://i.colnect.net/images/colnect_logo_255.png
Re: Sporadic ERROR: Unable to read cache file [message #73114 is a reply to message #72507 ] Sun, 22 February 2009 11:47 Go to previous messageGo to next message
colnector
Messages: 162
Registered: July 2008
Senior Member
Anyone?


Colnect Collectors Club Community
http://colnect.com

http://i.colnect.net/images/colnect_logo_255.png
Re: Sporadic ERROR: Unable to read cache file [message #73144 is a reply to message #72507 ] Mon, 23 February 2009 07:27 Go to previous messageGo to next message
skywalker  is currently offline skywalker
Messages: 334
Registered: March 2008
Location: Norway
Faithful Member
Which logfile? The application logfile or the webservers logfile?


May the source be with you
Re: Sporadic ERROR: Unable to read cache file [message #73158 is a reply to message #73144 ] Mon, 23 February 2009 09:04 Go to previous messageGo to next message
colnector
Messages: 162
Registered: July 2008
Senior Member
Application logfile. This is a Symfony exception.


Colnect Collectors Club Community
http://colnect.com

http://i.colnect.net/images/colnect_logo_255.png
Re: Sporadic ERROR: Unable to read cache file [message #73169 is a reply to message #72507 ] Mon, 23 February 2009 10:21 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
What platform are you on? Have you tried fix-perms, or to fix permissions manually? Is there anything in the Apache error log?


Remember Palestine
Re: Sporadic ERROR: Unable to read cache file [message #73179 is a reply to message #72507 ] Mon, 23 February 2009 11:27 Go to previous messageGo to next message
colnector
Messages: 162
Registered: July 2008
Senior Member
Latest apache2/php5/symfony1.1 over gentoo linux. I believe that had this error been constant, it wouldn't be possible to access my website. It is, however, sporadic.

I went through the logs to try and find a reason but couldn't yet. The server error log has nothing. The access log shows a 500 response. The requests r of different nature so it's not one thing. There are always a few requests logged at the same second and only one of them returns 500. May there be a problem accessing the files at the same time?

Now that I think it should be cached on APC, I'm wondering if the cache filling up may be the issue...

Any ideas?


Colnect Collectors Club Community
http://colnect.com

http://i.colnect.net/images/colnect_logo_255.png
Re: Sporadic ERROR: Unable to read cache file [message #73182 is a reply to message #72507 ] Mon, 23 February 2009 12:08 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
Hmm, intermittent errors are the worst kinds of errors to find Wink

Couple of things, depending on what time you have and what tests you are willing to carry out in live. First, perhaps turn up the loglevel in Apache, to see if anything else comes out. Long shot, it may be worth trying a different accelerator to see if there are any problems there.

Also, it may be worth doing some load testing to see if there is some interplay between PHP processes doing something to the cache at the same time. Do you do any selective cache removal in your application?


Remember Palestine
Re: Sporadic ERROR: Unable to read cache file [message #73187 is a reply to message #73182 ] Mon, 23 February 2009 12:17 Go to previous messageGo to next message
skywalker  is currently offline skywalker
Messages: 334
Registered: March 2008
Location: Norway
Faithful Member
Can it be that you hit some sort of resource limit on your system? I'm not sure, but perhaps the total number of open files?


May the source be with you
Re: Sporadic ERROR: Unable to read cache file [message #73201 is a reply to message #72507 ] Mon, 23 February 2009 12:45 Go to previous messageGo to next message
colnector
Messages: 162
Registered: July 2008
Senior Member
When does Symfony try to read the cache file? I guess that would be the place to look. I do believe something has changed in recent versions of Symfony1.1 that is causing that bug. My traffic has risen nicely but also the resources I give to the virtual host.

I highly doubt any apache or system limits are reached since it doesn't happen only when the site has a lot of traffic. Also, had file limits been the issue, I would have seen more errors on the system.


Colnect Collectors Club Community
http://colnect.com

http://i.colnect.net/images/colnect_logo_255.png
Re: Sporadic ERROR: Unable to read cache file [message #73204 is a reply to message #72507 ] Mon, 23 February 2009 12:49 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
Does this problem cause your users any problems, do you know? Or does it just recreate the thing from scratch it is trying to read? If your server can take it, it might be worth setting up some long-term low-level simulated user tests to see if you can reproduce any failures that may affect real users.


Remember Palestine
Re: Sporadic ERROR: Unable to read cache file [message #73206 is a reply to message #72507 ] Mon, 23 February 2009 12:55 Go to previous messageGo to next message
colnector
Messages: 162
Registered: July 2008
Senior Member
As I've written above, there are always matching 500 responses in the logs.

Which means AFAIK that my users get an occasional 500 error page that Symfony gives them. If it's someone who knows my site, they'll probably refresh and not mind much but if it's a first time visitor, I'm likely to lose here...

As the exception is caught by Symfony and handled by it, it's obviously there that I have to look for a solution.


Colnect Collectors Club Community
http://colnect.com

http://i.colnect.net/images/colnect_logo_255.png
Re: Sporadic ERROR: Unable to read cache file [message #73214 is a reply to message #73201 ] Mon, 23 February 2009 14:15 Go to previous messageGo to next message
skywalker  is currently offline skywalker
Messages: 334
Registered: March 2008
Location: Norway
Faithful Member
colnector wrote on Mon, 23 February 2009 12:45

When does Symfony try to read the cache file? I guess that would be the place to look. I do believe something has changed in recent versions of Symfony1.1 that is causing that bug. My traffic has risen nicely but also the resources I give to the virtual host.

I highly doubt any apache or system limits are reached since it doesn't happen only when the site has a lot of traffic. Also, had file limits been the issue, I would have seen more errors on the system.



You're right... it was only a wild guess from me.

Have you digged into the symfony core to see what is happening? If the code is throwing an exception, there is some test somewhere in the code that case this.


May the source be with you
Re: Sporadic ERROR: Unable to read cache file [message #73216 is a reply to message #72507 ] Mon, 23 February 2009 14:56 Go to previous messageGo to next message
colnector
Messages: 162
Registered: July 2008
Senior Member
I didn't start digging at Symfony's core yet, I was hoping this forum post might save me the trouble Smile


Colnect Collectors Club Community
http://colnect.com

http://i.colnect.net/images/colnect_logo_255.png
Re: Sporadic ERROR: Unable to read cache file [message #73700 is a reply to message #72507 ] Sat, 28 February 2009 18:54 Go to previous messageGo to next message
colnector
Messages: 162
Registered: July 2008
Senior Member
The exception comes from
/symfony/lib/cache/sfFileCache.php line 212
(as a side note, all this info should be in the error log file by default...)

Anyway I've worked around changing:
    if (!$fp = @fopen($path, 'rb'))
    {
      throw new sfCacheException(sprintf('Unable to read cache file "%s".', $path));
    }


Into:
    if (!$fp = @fopen($path, 'rb'))
    {
    	sleep(2);
      if (!$fp = @fopen($path, 'rb')) throw new sfCacheException(sprintf('Unable to read cache file "%s".', $path));
    }


Let's see if it works...


Colnect Collectors Club Community
http://colnect.com

http://i.colnect.net/images/colnect_logo_255.png
icon14.gif  Re: Sporadic ERROR: Unable to read cache file [message #73737 is a reply to message #73700 ] Sun, 01 March 2009 14:54 Go to previous messageGo to next message
colnector
Messages: 162
Registered: July 2008
Senior Member
This is so far working well although it's just a workaround


Colnect Collectors Club Community
http://colnect.com

http://i.colnect.net/images/colnect_logo_255.png
Re: Sporadic ERROR: Unable to read cache file [message #79641 is a reply to message #73737 ] Tue, 09 June 2009 23:08 Go to previous messageGo to next message
rknepp  is currently offline rknepp
Messages: 1
Registered: June 2009
Junior Member
I have a similar/related problem.

I believe the work-around above (i.e. sleep and try fopen again) would solve the problem but I do not have access to the core code in our production environment.

For me, the problem only appears after a symfony cc - particularly when the system is hit simultaneously by multiple users immediately after the cache clear.

I can reproduce the problem easily using a jMeter test with 20 users and loop count of 1:
1) symfony cc
2) start jmeter test against simple URL
3) approximately 10-15 responses come back with no content and error 500 (a few are 404's) before I start to get the correct data back.
4) checking the apache logs I see errors regarding cache files
5) once the data starts coming back correctly, all further tests run great (I could hit it with 1000 users loop count 20 and it would work great).

[Tue Jun 9 15:10:45 2009] [error] Unable to read cache file "/path_to_htdocs/cache/myapp/prod/config/routing/symfony.routing.configuration.cache".
[Tue Jun 9 15:10:46 2009] [error] PHP Warning: require(/path_to_htdocs/cache/myapp/prod/config/config_config_handlers.yml.php) [function.require]: failed to open stream: No such file or directory in /path_to_symfony/config/sfConfigCache.class.php on line 276
[Tue Jun 9 15:10:46 2009] [error] PHP Fatal error: require() [function.require]: Failed opening required '/path_to_htdocs/cache/myapp/prod/config/config_config_handlers.yml.php' in /path_to_symfony/config/sfConfigCache.class.php on line 276


My assumption is that the core code is in process of building up the cache files while many users are attempting to read them at once. Since the cache files do not exist yet (at least not completely) some users get a 500 errors.

I have a few questions and hope someone can help - hopefully I am not completely off-base.

1) I am unable to get 'check_lock' settings to work. I'm not positive it would even fix my problem. I've been through the docs/examples many times with no success. Is this something I should pursue further?

2) Is there a way to pre-populate the yml cache files after/during a symfony cc? I believe this would be helpful in resolving the issue.

3) What is the suggested procedure for disabling symfony apps prior to symfony cc? I could disable,symfony cc, rebuild cache, then re-enable... if that's even possible. My clients would not have access during that time, but at least it would give them consistent return content while the system is being restarted.

4) Is this a common problem and/or will it be resolved in future versions? Or perhaps it has already? I'm using 1.2.5

My company has converted our entire SOAP API system to a symfony-based REST API and the load is immense at times. I'm worried that clearing cache will have a negative impact on our clients consuming the responses - especially if they get no content back.


Or maybe I'm missing something?



Anyway, first time poster so please be gentle.

- Bob
Re: Sporadic ERROR: Unable to read cache file [message #80157 is a reply to message #72507 ] Thu, 18 June 2009 17:26 Go to previous messageGo to next message
benhaines  is currently offline benhaines
Messages: 62
Registered: August 2006
Location: London
Member
Couple of things I would try:

- try different configuration and build of LAMP, a wierd problem I had a few months ago was due to build of PHP I was running, never actually tracked down the issue though

- try the mailing lists, most of the 'experts' listen in including Fabien & co at Sensio Labs, you might get more luck there

Good luck.
Re: Sporadic ERROR: Unable to read cache file [message #82911 is a reply to message #72507 ] Thu, 30 July 2009 17:32 Go to previous messageGo to next message
robny  is currently offline robny
Messages: 34
Registered: March 2008
Member
I'm experiencing this same thing in a production environment. It is definitely not related to permissions.

I suspect, but cannot prove, that it has to do with file-locking and concurrency under load. Simultaneous access to the an action that has no cache results in both instances trying to create the cache file.

I only experience this after a code-migration (via rsync) and a symfony cache flush. I can duplicate fairly readily using apache benchmark to stress an action.

Re: Sporadic ERROR: Unable to read cache file [message #82916 is a reply to message #82911 ] Thu, 30 July 2009 18:33 Go to previous messageGo to next message
colnector
Messages: 162
Registered: July 2008
Senior Member
Please see my workaround above. It does relate to the problem and since then my server's working pretty well. Do mind that configuring APC-cache to not re-read any of your files will help this as well. Then you'll naturally have to do an apache graceful restart whenever you'd like an update to be processed. Good luck Smile


Colnect Collectors Club Community
http://colnect.com

http://i.colnect.net/images/colnect_logo_255.png
Re: Sporadic ERROR: Unable to read cache file [message #82917 is a reply to message #82916 ] Thu, 30 July 2009 18:43 Go to previous messageGo to next message
robny  is currently offline robny
Messages: 34
Registered: March 2008
Member
Thanks for the reply. Changing the symfony core is not really what I like to do in these situations; although I've developed a slightly more robust patch that addresses this thundering herd issue -- it is still ugly.

By the way, I'm also getting these exceptions thrown when writing to the cache. Same cause, I presume.

Re: Sporadic ERROR: Unable to read cache file [message #82919 is a reply to message #82917 ] Thu, 30 July 2009 19:05 Go to previous messageGo to next message
colnector
Messages: 162
Registered: July 2008
Senior Member
The way I view it, Symfony is another piece of the very complex puzzle that makes up my web server. Whatever makes it work better is welcomed and nothing's holy. A framework is there to help me and sometimes a patch that matters for me is a good thing.


Colnect Collectors Club Community
http://colnect.com

http://i.colnect.net/images/colnect_logo_255.png
Re: Sporadic ERROR: Unable to read cache file [message #82921 is a reply to message #72507 ] Thu, 30 July 2009 20:03 Go to previous messageGo to next message
robny  is currently offline robny
Messages: 34
Registered: March 2008
Member
I'm also experiencing similar exceptions that have been traced to the writeAndControl method of sfFileCache.

A post elsewhere http://devtime.blogspot.com/2008/05/unable-to-write-config-c ache-for.html had success by disabling SELINUX.

I'm on Ubuntu. Anyone know of anything along these lines which might be causing these filesystem issues?

(and yes, the temporary patches are working. I added some logging to highlight when the patches kick in.)

BTW: I'm running 1.0.20


Re: Sporadic ERROR: Unable to read cache file [message #97090 is a reply to message #72507 ] Sat, 10 April 2010 17:05 Go to previous message
cestcri  is currently offline cestcri
Messages: 232
Registered: August 2007
Location: Paris
Faithful Member
Hi all,


I have the exact same issue, and tried now your suggested sleep for 2 seconds. Unfortunately I still get those nasty errors.


Apr 10 16:33:48 symfony [err] {sfCacheException} Unable to read cache file "/cache/frontend/prod/template//ffindr_com/all/sf_cache_partial/slot/_mat/sf_cache_key/ru.cache".
Apr 10 16:35:03 symfony [err] {sfCacheException} Unable to read cache file "/cache/frontend/prod/template//ukraine_ffindr_com/all/sf_cache_partial/slot/_mat/sf_cache_key/ru.cache".
Apr 10 16:44:32 symfony [err] {sfCacheException} Unable to read cache file "/cache/frontend/prod/template//germany_ffindr_com/all/sf_cache_partial/slot/_mat/sf_cache_key/de.cache".
Apr 10 16:45:20 symfony [err] {sfCacheException} Unable to read cache file "/cache/frontend/prod/template//ukraine_ffindr_com/all/sf_cache_partial/slot/_mat/sf_cache_key/ru.cache".



I delete those cache entries each time something is posted or modified on my page (i.e. often), and unfortunately those errors get triggered very frequently. I agree on the assumption that simultaneous access causes the problem since I have a highly frequented website.


Any other ideas? For now I set the sleep to 3 seconds, but I do not think that this will help.

Thanks in advance,
Christian
Previous Topic:Doctrine where vs addWhere vs andWhere
Next Topic:Cache: avoid creation of one cache file per subdomain
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software