views:

102

answers:

2

Hello Stack Overflowers,

I am running into an issue that is leaving me in a dead end so in turn, I turn to you! Recently a Symfony app has been going down rendering an internal apache error -500. After deleting the Symfony cache the site comes back up. Upon some further investigating I have found the error of "Premature end of script headers: php5". The site has not produced any errors like this in over 1year and we have not made any changes to this site and this has been happening regularly(once a week). The following is from the log files.

[Sat Aug 28 06:20:30 2010] [error] [client 206.131.184.1] Premature end of script headers: php5

This email was also sent recently from MT, possibly related that I feel may directly relate to the issue.

It has come to our attention that your service ----.com, has been generating an unusually large number of file system locks on the cluster which hosts your account. Websites or scripts which utilize NFS file locking incorrectly can often generate this error, which inordinately affects the performance of the cluster for other customers. This is a violation of our AUP which can be found at 'http://mediatemple.net/company/legal/aup_general.php'.

We tracked the file locking issue to the following file which is being locked repeatedly:

/domains/----.com/symfony/cache/frontend/prod/config/routing/symfony.routing.configuration.cache /domains/----.com/symfony/cache/frontend/prod/config/routing/symfony.routing.data.cache

We recommend you immediately disable file locking for your scripts if the option is available (often located in the configuration section of the script); or use a different script which does not utilize file locking. Any future locking abuse by this script may result in the suspension of traffic to this domain to prevent the locking from affecting other customers.

If you have any questions regarding this file locking issue, or are not sure where to begin with disabling file locking, please respond to this ticket for further assistance.

+1  A: 

I think it's safe for you to disable Symfony's cache locking for reads in lib/cache/sfFileCache.class.php in method read(). Symfony takes a share lock when reading. The lock is not necessary because Symfony uses a temporal file and rename when writing. Also, in lib/log/sfFileLogger.class.php the lock in doLog() method is not necessary, since the write is atomic (single fwrite() call), and the file is opened in append mode.

I haven't tested how these changes would affect Symfony.

"Premature end of script headers" is not a PHP error message. The web server is issuing this message when the backend (PHP in this case) does not send headers. This is most likely because it dies before it's able to do anything. You should locate PHP error log and see the real error message. However, note that Symfony uses a lot of @ for error suppression in function calls so you may not find anything.

jmz
Thank you, I am hoping this in unison with @kuba's info we should be ok.
jnolte
jmz +1 for your help with this. I did fix this and there is no more file locking, but I do not feel this was the root of the main issue. It definitely helped with a secondary part of the problem but the sfFileCache was the culprit. Thanks again!
jnolte
+1  A: 

Recently I encountered similar issue. Replacing file caching with APC solved my problems completely. I needed to replace sfFileCache for view_cache, i18n cache and routing.

If APC is not available on your server than you can easily use any other popular accelerator instead.

How to use APC with symfony: http://www.zalas.eu/symfony-meets-apc-alternative-php-cache

kuba
thanks for the insight @kuba I have just implemented and am hoping for the best.
jnolte
Don't forget to write if it helped or not ;)
kuba
After some time the site seems to be working great and this did the trick. Thanks a million!! Sorry for the delay, I wanted to make sure the site was resolved.
jnolte