How do I push module update in a cached production environment? I don't manage to update Flag module in remote server, while it worked like a charm on local environment. The stage site is cached with Zend opcache, Apcu, Varnish and Redis. I suspected Opcache was faultier but no way to get it work.

The steps I did (local dev) :


drush up flag -y
drush cc all. Tested flag features, OK.
Commited &amp; pushed files to stage on a flag branch


The steps then on remote server :


git checkout flag
Reset Opcache various times (thanks to this great Opcache GUI)
Saved database
Ran update.php, which returned 

flag module
7300 - Rebuild the class registry due to classes moving files.
7301 - Rename {flag_content} table to {flagging} and {flags} table to {flag}.
7302 - Rename database columns on the {flag} table.
7303 - Rename database columns on the {flagging} table.
7304 - Rename database columns on the {flag_counts} table.
7305 - Convert flag roles to permissions.
7306 - Convert flag view modes settings.

Ran Apply pending updates, which retunred An unrecoverable error has occurred, Ajax error, http status 200, followed by 4 notices. These notices are known, but caused no update crash on local site.
if I go to the "error page", I'm sent back to Review updates page.


If I try to visit dblog, I have this fatal php error : Class 'flag_flag' not found in profiles/commons/modules/contrib/flag/flag.module on line 1948. But if I check the remote files, I can find that class in profiles/commons/modules/contrib/flag/includes/flag/flag_flag.inc . 

I invalidated that file namely in Opcache and invalidate full Opcache. I also checked in varnish.vcl that update.php is in the list of bypassed URL.

Then after a while, Varnish finds backend server is not responding and boom : Error 503 Backend fetch failed, ending restarting php5-fpm...

To be honest, I understand about nothing anymore, "eating my hat" or "banging my head" or how would you say that ? Help really welcome !
Short answer : make extensive use of drush !

This was quite straightforward  and successful, though I'm still not really sure if I have to empty both opcache and Varnish. This would be a huge performance hint on production server. IMO the best would be to invalidate only the changed files in opcache and voilà ?

Steps I did (local dev) :


drush up flag -y
drush cc all
tested flag features, OK.
commited &amp; pushed files to stage on a flag branch


The steps then on remote server :


git checkout flag
varnishadm -T 127.0.0.1:6082 -S /etc/varnish/secret (enter Varnish Cli)
varnish&gt; ban req.http.host ~ dev.example.com &amp;&amp; req.url ~ . (clear varnish cache)
reset Opcache with Opcache GUI
drush updb
drush rr (optional in that case since this was performed in flag_update_7300)