Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Cache] LockRegistry::compute() does not acquire a lock and gets into a recursive loop with semaphores #44536

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

Closed
mbabker opened this issue Dec 9, 2021 · 1 comment

Comments

@mbabker
Copy link
Contributor

mbabker commented Dec 9, 2021

Symfony version(s) affected

5.4

Description

Our application has AsyncAwsBundle and LiipImagineBundle installed, and when there are multiple (almost concurrent) requests to the liip_imagine_filter route, we're seeing a recursive loop in Symfony\Component\Cache\LockRegistry::compute() when the AsyncAws client is trying to fetch the credentials from its cache provider (this is in its default configuration which is using the cache.app cache pool and we have this set up to use Redis for our production and staging environments). When I run the liip:imagine:cache:resolve command on the system once the lock registry starts looping, we just end up with a wall of repeating log messages in the output and it never breaks out of this loop:

15:34:21 INFO      [cache] Item "AsyncAws.Credentials.5884dee2d3b4afa9c984f7b747a58f87f4af89c9" is locked, waiting for it to be released
15:34:21 INFO      [cache] Item "AsyncAws.Credentials.5884dee2d3b4afa9c984f7b747a58f87f4af89c9" not found while lock was released, now retrying

When I monkey patch the class to not use semaphores at all, everything seems to work normally.

Our production environment uses Docker images built on top of Ubuntu 18.04 with PHP 8.0 installed from the ondrej/php PPA and the web interface is using PHP-FPM.

How to reproduce

Unfortunately, I don't have time at the moment to break this down to a small reproducer, the steps above have been pretty reliable to trigger the problem in our environment but I imagine there's probably a simpler way to do it.

Possible Solution

No response

Additional Context

No response

@nayzo
Copy link
Contributor

nayzo commented Dec 15, 2021

I'm encountering the same issue with Redis after upgrade from Symfony v5.3 to Symfony v5.4
PS; I'm using PHP 7.2 on Debian 8

nicolas-grekas added a commit that referenced this issue Dec 16, 2021
…aphores when possible" (nicolas-grekas)

This PR was merged into the 5.4 branch.

Discussion
----------

[Cache] Revert "feature #41989  make `LockRegistry` use semaphores when possible"

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #44536
| License       | MIT
| Doc PR        | -

This reverts commit 479919d, reversing
changes made to 356c953.

I'd like to revert this PR because using semaphores is creating problems that don't have any easy solution.

Commits
-------

6bcc3cb Revert "feature #41989 [Cache] make `LockRegistry` use semaphores when possible (nicolas-grekas)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants