|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59068 apc_inc / apc_dec NOT atomic
Submitted: 2010-02-10 01:30 UTC Modified: 2016-11-18 21:54 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: jasonwyz98 at gmail dot com Assigned:
Status: Wont fix Package: APC (PECL)
PHP Version: 5.2.6 OS: Ubuntu v9.04
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: jasonwyz98 at gmail dot com
New email:
PHP Version: OS:


 [2010-02-10 01:30 UTC] jasonwyz98 at gmail dot com
Please note I'm using the SVN trunk version of APC downloaded on 2/9/2010.

The new functions apc_inc() and apc_dec() are supposed to be atomic, but according to my tests there may be bugs.

Reproduce code:
apc_add( 'count', 0 );

apc_inc( 'count', 1 );

1. Run file1.php to add "count" to apc

After running file1.php, "count" should be 0 now

2. Run the command "ab -n 10000 -c 100 http://localhost/file2.php"

Expected result:
count = 10000

Actual result:
count = 10013

Please note different tests shows different numbers, usually a number close to 10000.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-02-10 02:59 UTC]
Hrm.. I ran this on an Ubuntu 9.10 box here.  20 times.  
Each time I got exactly 10000.  From the top of the apc.php 

1 Segment(s) with 32.0 MBytes 
(mmap memory, pthread mutex locking)

Did you compile it with the same locking mechanism?  Also, 
can you grep your log and verify that you have exactly 10000 
requests for file2 in there for one of these failed tests?  
I could see going under 10000 if Apache dropped one of your 
requests.  But going over?
 [2010-04-21 08:22 UTC] apc at tequilasolutions dot com
From the man page:

"Caches a variable in the data store, only if it's not already stored."

Maybe it was already cached at 3?
 [2016-11-18 21:54 UTC]
-Status: Open +Status: Wont fix
 [2016-11-18 21:54 UTC]
APC is no longer supported in favor of opcache that comes bundled with PHP, if you wish to use the user cache, then look at PECL/APCu.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 20 22:01:29 2024 UTC