php.net |  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
Votes:1
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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jasonwyz98 at gmail dot com
New email:
PHP Version: OS:

 

 [2010-02-10 01:30 UTC] jasonwyz98 at gmail dot com
Description:
------------
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:
---------------
file1.php:
apc_add( 'count', 0 );

file2.php:
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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-02-10 02:59 UTC] rasmus@php.net
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 
page:

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] kalle@php.net
-Status: Open +Status: Wont fix
 [2016-11-18 21:54 UTC] kalle@php.net
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 Mar 28 22:01:26 2024 UTC