Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

we are using capistrano to deploy our PHP application. and php-apc is enabled on the production server with apc.stat = 0. In capistrano config there is a rule to clear apc cache after deploy:update :

after "deploy:update", "clear_apc_cache"

the cache is successfuly cleared: apc.php 'View Host Stats' shows an uptime of 0 minute, numbers of cached files & hits is close to 0 (not 0 because there is quite a lot of traffic and some files are cached before we can check apc.php)

the problem is, sometime an old file is still cached in apc. I think this is due to an HTTP request starting before capistrano update the 'current' symlink and ending after we clear apc cache. in that case, file included after apc clear in this request are still from the old revision folder (we are using relative path in include*s and require*s) and are saved in apc cache

Is there a way to permanently fix this? without updating all include*s and require*s?

for now I will try to delay the "clear_apc_cache" for one or two second but I'm afraid it will cause others problems during the delay (and some requests could still be longer than 2 seconds)

share|improve this question

1 Answer 1

This answer states you need to pass an argument to clear_apc_cache and that only with apc.enable_cli=1 will the APC cache clearing work through CLI calls.

You might want to clear_apc_cache again with the after:restart hook to ensure the previous release is fully cleared.

share|improve this answer
    
well, clear_apc_cache is not call directly with a PHP-CLI call, the capistrano receipe use curl to call a script to clear the cache (and the cache is cleared) the problem is that current request fill the empty cache with opcode from the previous release –  Mathieu Aug 7 '13 at 20:27
    
@Mathieu see the after:restart note –  parhamr Aug 7 '13 at 20:43
    
nothing changes by clearing the cache a second time with after:restart. Unfortunately I think the two only solutions are to either fix the relatives includes* and requires* or to use a long enough delay –  Mathieu Aug 11 '13 at 21:00
    
@Mathieu is the PHP service ever restarted during the deployment? I have also used that as a fallback “nuke everything” operation. –  parhamr Aug 14 '13 at 18:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.