-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
Cache: Inconsistent behaviour regarding locks when clearing cache #52344
Comments
Thank you for reporting this issue! As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub. If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team. Thank you! |
Hi everyone, Could you review this PR and check if the way to reproduce the issue is acceptable? Thanks. |
That is kinda by design. We have two configs for the redis cache We have this Lines 74 to 78 in cfe5f84
That will determine which connection is used for the cache. Be advised that there is a difference in the default values of these two entries And then we have this Lines 153 to 169 in cfe5f84
The cache:clear will use framework/src/Illuminate/Cache/RedisStore.php Line 248 in cfe5f84
This will only flush the current database, because we don't want to interfere with other databases inside redis. You can change that behaviour by either change the database for locks in redis or change the behaviour of the cache clear command in your own application and replace the RedisConnection with your own class here framework/src/Illuminate/Redis/Connections/PhpRedisConnection.php Lines 496 to 505 in cfe5f84
|
Yes, I found that solutions with two Redis connections after hours of debugging. I'm okay with it being by design, but what threw me off was the different behaviour between drivers. I just checked the |
It seems odd, in order to keep consistency, the best solution may be to set
When
The inconsistency arises because only the redis instance executing the |
But that is indeed how it is supposed to work. In order to separate the locks from the actual values be use different databases, these values are saved inside database 1. The cache clear command is intended to clear the values from database 1. In order to flush all locks we need to have a separate logic that will flush database 0 for us. You can do: |
While I wrote the answer, I though about it again and have to say that dropping the locks is kinda an expected behaviour, because we also drop the data at the moment |
Oh, I get it now 😯, I initially thought it was a bug. |
Thabks @Katalam |
@crynobone Not sure why this was closed. It's not really solved. I think we should find a consensus on whether it's expected to clear locks when clearing the cache or not. Since it might break existing workflows, maybe the best idea is to introduce a new command and mention it in the docs? |
issues should focus on confirmed bug. Feel free to continue the discussion or submit a PR to the documentation etc. |
Laravel Version
11.19.0
PHP Version
8.3
Database Driver & Version
Redis
Description
There is an inconsistency when clearing the cache between the Redis store and the file store. The file store also clears locks, while the redis store doesn't. This affects unique queued jobs. While you can reset the job locks through
artisan cache:clear
when using the file store, this doesn't work with the redis store, leaving you confused why no jobs are pushed to the queue.Steps To Reproduce
When
CACHE_STORE
is set toredis
Laravel behaves like this:When
CACHE_STORE
is set tofile
Laravel behaves like this:The text was updated successfully, but these errors were encountered: