Ruhi Singh
Ruhi Singh

Reputation: 186

Php files not getting updated after deploy even after clearing xcache

Facing this strange problem that if I deploy my code, and even clear the xcache, then also the code is calling some of the old files. This behaviour is random. I checked the xcache , it is getting clear every time but still some times it works fine then again try to access the old file and some how go fine. This problem is not with js or css as we maintain version for them ,but it is in case of php classes and functions.

I am not at all getting any idea from web or otherwise why this is happening.I also tried touching all the files but same issue exist even with more frequency. I am using LAMP environment with xcache and deploying releases through capistrano. I verified xcache clear from its admin. Tried different versions of xcache but no help.

May be the case is following but I don't have solution for this as well : If we have a long request processing, we deploy and symlink changes in between and if this request include another file, then both the old and new files get included causing the issue.

Please suggest where I can move further.

Upvotes: 0

Views: 887

Answers (2)

k0tl4rz
k0tl4rz

Reputation: 1

My case scenario involved an over-optimized opcache setting on my shared hosting account in user.ini file, which considered this:

opcache.memory_consumption=2024
opcache.interned_strings_buffer=64
opcache.max_accelerated_files=1000000
opcache.max_wasted_percentage=10
opcache.revalidate_freq=10
opcache.fast_shutdown=1
opcache.enable_file_override=0
opcache.max_file_size=0
opcache.validate_timestamps=0
opcache.revalidate_path=0
opcache.use_cwd=1

under PHP 5.6

$smarty->clearAllCache();
clearstatcache();
opcache_reset();
opcache_invalidate();

didn't managed to clear the cache. Only an updated version of the ini file, with commented out opcache settings, allowed me to free the cache (otherwise server restart or 4 days of waiting).

Upvotes: 0

Jasper N. Brouwer
Jasper N. Brouwer

Reputation: 21817

When you change a file while it's being used, you are bound to get problems.

You'll need to completely stop the application before you switch the symlink.

In the Capistrano community this in known as "maintenance mode". You can find lots of information (on Google) about implementing this concept.

Basically you set your application in "maintenance mode", which will cause it to fend off (web) requests without them reaching PHP and stop any long-running processes (crons, daemaons, etc). How you implement this highly depends on your application's architecture.

When the application is completely idle, it's safe to switch the symlink, then clear caches, then spinning it back up.

Upvotes: 1

Related Questions