php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #58468 apc_add() blocks until end of script
Submitted: 2008-12-18 17:23 UTC Modified: 2009-04-13 14:50 UTC
From: dennis dot birkholz at nexxes dot net Assigned:
Status: Closed Package: APC (PECL)
PHP Version: 5.2.6 OS: Gentoo/Linux
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: dennis dot birkholz at nexxes dot net
New email:
PHP Version: OS:

 

 [2008-12-18 17:23 UTC] dennis dot birkholz at nexxes dot net
Description:
------------
The manual says that apc_add() will return false if a variable with the supplied name is already in the cache. But if another script runs and has just created a cache variable with the same name (and script execution is not yet finished), the current script blocks until the other script has finished.

Run the supplied testscript twice and you will see that is does not work like it is documented.

Maybe an apc_flush() function can be added to cause APC to flush and release locks immediately??

Reproduce code:
---------------
<?php

if (apc_add("testvar", true, 60) {
	print "Variable created.<br>\n";
	flush();
	sleep(5);
	apc_delete("testvar");
	print "Variable removed.<br>\n";
} else {
	print "Variable exists.<br>\n";
}

?>

Expected result:
----------------
Script 1:
Variable created.
[5 seconds later]
Variable removed.

Script 2:
Variable exists.

Actual result:
--------------
Script 1:
Variable created.
[5 seconds later]
Variable removed.

Script 2:
[5 seconds later]
Variable created.
[5 seconds later]
Variable removed.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-18 17:26 UTC] dennis dot birkholz at nexxes dot net
I should add that the "problem" is present in the current "stable" 3.0.19 and in the "beta" 3.1.12
 [2008-12-18 20:19 UTC] shire@php.net
Thank you for taking the time to write to us, but this is not
a bug.

APC doesn't currently support sharing caches between different CLI processes.  If you repeat this process within an Apache server environment, you should see the expected results.  If you do see this in Apache, please re-open.  Thanks.
 [2008-12-19 09:42 UTC] dennis dot birkholz at nexxes dot net
This problem happens with Apache 2.2.9 and php 5.2.6 installed as sapi module, so no cli or cgi is involved here!
 [2008-12-22 04:57 UTC] gopalv82 at yahoo dot com
I just tested this out with my apache2/php5.3 install and it seems to work as expected?


$ curl http://localhost:8080/15350/
Variable created.<br>
Variable removed.<br>

$ curl http://localhost:8080/15350/
Variable exists.<br>

in parallel. 

apache-2.0.52/php5.3.0alpha3-dev. How exactly are you testing it? In a browser? with the browser cache disabled?
 [2009-03-02 03:03 UTC] shire@php.net
Can you provide any more details per Gopal's comments?  Is this still a problem?
 [2009-03-02 03:32 UTC] dennis dot birkholz at nexxes dot net
I tested this problem using my webbrowser as well as using curl and wget.
I will next upgrade my system to the latest php and apc versions to test if the problem still exists, but I cannot do so until after the 18th of march, so please be patient for my reply.

Thank you for working on this bug.
 [2009-03-02 14:34 UTC] shire@php.net
Sounds good, we'll wait until after the 18th, to hear from you about your latest tests.  Thx.
 [2009-04-05 23:28 UTC] shire@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2009-04-10 08:14 UTC] dennis dot birkholz at nexxes dot net
Sorry for the delay in my response, my exams did not when that well as hoped so I had to take some second tries.

I could not verify that "problem" any more. Both installations (apache 2.2.9 with php 2.2.8 and apache 2.0.59 with php 2.2.9, both apc 3.0.19) did not show it any more.

Thank you for your patience and your work on my problem!
 [2009-04-13 14:50 UTC] shire@php.net
Understood, thanks for the update.  Please re-open this issue if you are able to reproduce it again of course.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 18:01:32 2024 UTC