Search code examples
phpapcoutputcorruption

APC is corrupting output


I've recently switched my web server to Centos 6.3, with apache 2.2.15, PHP 5.4.11 and APC 3.1.14.

I started receiving complaints from customers from time to time, that a page is not working, or strange errors appear. I saw that the affected pages have question marks and other strange symbols in random places in the output, even though the sources are OK. When I change a single letter in the source file, the page starts working fine.

I suspect APC, but I cannot find any clue when and why this happens.

I use mercurial to push changes to production, but I've used this approach for years with no problem. Maybe something in the configuration is new now, but sadly I don't keep my old configuration.

Below is a screenshot from the last corruption.

screenshot from a corrupted ajax response

Edit: Here's the response after I've changed a single character in the source, saved it, and then undo the files (same is if I just restart the web server or clear APC opcode cache):

screenshot after a fix

Notice the line numbers didn't match, but it's 100% the same request, so the response should be the same also. The line 111 from the first screenshot should not be there at all. It seems that it's from another source file...


Solution

  • I've changed apc.stat_ctime to 1

    Verification with ctime will avoid problems caused by programs such as svn or rsync by making sure inodes haven't changed since the last stat. APC will normally only check mtime.

    I'll be watching closely on the problem, because it's occurring once or twice a week and post here if this fixed it.