php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57988 apc_store() and apc_fetch() does not work correctly with multiple cpus systems
Submitted: 2008-01-01 16:10 UTC Modified: 2008-01-02 02:47 UTC
From: joe7 at site dot hu Assigned:
Status: Not a bug Package: APC (PECL)
PHP Version: 4.4.4 OS: Unix/Debian
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
21 - 9 = ?
Subscribe to this entry?

 
 [2008-01-01 16:10 UTC] joe7 at site dot hu
Description:
------------
Unfortunately there is a serious problem with apc_fetch/store on systems with multiple cpus or dual/quad core systems.

Reproduce:
<?php
$bar = 'BAR';
apc_store('foo', $bar);
var_dump(apc_fetch('foo'));
?> 

is good, but after this you just run:
<?php
var_dump(apc_fetch('foo'));
?> 

several times, and you can get
FALSE instead of the value even if you set ttl of 1000+


There is a forum post about this at
http://litespeedtech.com/support/forum/showthread.php?t=1566

Reproduce code:
---------------
<?php
$bar = 'BAR';
apc_store('foo', $bar);
var_dump(apc_fetch('foo'));
?> 

<?php
var_dump(apc_fetch('foo'));
?> 

Expected result:
----------------
'BAR'

Actual result:
--------------
FALSE

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-02 02:47 UTC] rasmus@php.net
This has nothing to do with APC.  You are using a web server which launches multiple parent processes.  Each one is going to get its own APC shared memory segment, so when you do an apc_store() you are storing it in the segment belonging to the process you happen to hit and subsequent fetches may or may not hit that same process.

With Apache, there is a single parent process which spawns a bunch of child processes.  The shared memory segment is created in the parent process and inherited by the children so they all see the same one.  I really haven't tested configurations that don't follow this pattern, but you could remove the unlink() call in apc_mmap.c in the "normal filesystem mmap" section there and set apc.mmap_file_mask=/tmp/some_file_name

By not unlinking it, you get a regular file-backed mmap happening without owner-death protection, but multiple processes should hit the same file and thus the same shared memory segment.  In theory anyway.  Let me know if it works, but there is no bug here.  It is more of a feature request to make APC handle non-forking multi-process configurations.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 12:01:29 2024 UTC