-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
apcu_inc stucks on pthread_rwlock_wrlock #416
Comments
Usual question: Is it possible that an opcache restart occurred before the deadlock? (An "Attempting to kill locker" in opcache log at opcache.log_verbosity_level=2.) |
I can now easily reproduce the issue. Just restart the httpd and send it a request .. I set the opcache.log_verbosity_level=4 and only see the following logs while the deadlock occurs.
|
@nikic I finally figured out the minimal code to reproduce the issue. <?php
header("Content-Type: text/plain");
function request_identifier()
{
return apcu_entry("started_at", function(){return time();}, 999999) . apcu_inc('index');
}
$v = apcu_entry("HELLO", function(){
return request_identifier() . ' hello';
}, 3600);
echo 'value: '. $v, "\n";
echo 'success'; Steps:
Result: dead locked. |
See the documentation for apcu_entry (https://www.php.net/apcu_entry):
Calling any apcu function inside apcu_entry will indeed deadlock (at least when using rwlocks). I think it's time to deprecate this function and replace it with one that doesn't guarantee a critical section. |
I see. Thank you. Do you think it's a good idea/possible to report a fatal error in this scenario? The function that guarantee a critical section is sometimes useful in my mind. The generator in our code is a function to fetch some data from the model layer which is a little deep, such that some other apcu function is involved unfortunately. |
@gaohuia I've pushed 61f3c16, which adds checks for read lock failure. This should throw a warning and avoid a deadlock, at least if posix rwlocks are used. For your example, under
|
After 6e73f57, it should be safe to call other apcu_* functions inside apcu_entry(). |
Hi, we are running into deadlocks on debian10 / litespeed with lsphp + plesk-php7.3 + acpu 5.1.19. I can reproduce the locks with your short php-script. is this case related to #410 and might your patch fix this issue too? I use now master ( 6e73f57 ) and can't break the server anymore. I will report if the shopware installation is now working without breaking. |
https://github.com/krakjoe/apcu/releases/tag/v5.1.20 with a fix for this issue has been released. Please tell me if you still encounter problems. |
Hi I met this issue twice these days. We have two servers, the issue exists on both of them. New requests were just blocked and end with 504.
GDB:
PHP Version: PHP 7.3.21
apcu version 5.1.18
The text was updated successfully, but these errors were encountered: