-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Invalid Redis socket DSN, the "dbindex" parameter must be a number. #44215
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
Comments
/cc @a1812 could you please have a look? |
Looks like the code wants to use the URL path both for the unix scoket path and the DB index at the same time |
I have the same issue, my env parameter: |
Anyone up for a PR fixing this? |
I think the fix for the dbindex would be to look for it only if we have |
if we are talking about format like this However, I think this might be more complicated, need to test all other parameters and other variations |
based on https://symfony.com/doc/current/components/cache/adapters/redis_adapter.html and using format
|
5.3.11 broken for
|
…kas) This PR was merged into the 4.4 branch. Discussion ---------- [Cache] fix connecting to local Redis sockets | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #44215 | License | MIT | Doc PR | - Commits ------- 954db3f [Cache] fix connecting to local Redis sockets
We get the error in 5.3.12. Hasn't this been merged into the 5.3 branch? |
The patch is in 5.3.12 I confirm. |
Hi, @nicolas-grekas This is the diff between 5.3.10 and 5.3.11 (5.3.10 works): - if (!isset($params['dbindex']) && isset($params['path']) && preg_match('#/(\d+)$#', $params['path'], $m)) {
- $params['dbindex'] = $m[1];
- $params['path'] = substr($params['path'], 0, -\strlen($m[0]));
+ if (!isset($params['dbindex']) && isset($params['path'])) {
+ if (preg_match('#/(\d+)$#', $params['path'], $m)) {
+ $params['dbindex'] = $m[1];
+ $params['path'] = substr($params['path'], 0, -\strlen($m[0]));
+ } else {
+ throw new InvalidArgumentException(sprintf('Invalid Redis DSN: "%s", the "dbindex" parameter must be a + number.', $dsn));
+ } What was the reason for this change? |
What is linked in this issue: see #43359 |
Okay. Could we reopen this issue? |
I have the same problem as @loevgaard with 5.3.12 What is weird in one project it works OK, in another one it doesn't work, while on both of them I have symfony/cache 5.3.12 |
(removed) The new problem is addressed here: #45277 (comment) |
@thomas2411 @mathielen you're affected by #45277, not by this issue. @loevgaard do you have more insights about your issue about dbindex, or does #45281 also fix you issue? |
I am not experiencing this problem anymore, however, can't be quite sure because I don't quite remember how I triggered the problem (forgot to jot it down :() |
OK, please report back with details when you can. |
Okay, just got this error again: It happens in here: https://github.com/symfony/symfony/blob/6.3/src/Symfony/Component/Cache/Traits/RedisTrait.php#L153. The |
Can you send a PR if you have the fix please? |
Yes, I will, @nicolas-grekas. Thanks! |
There you have it, @nicolas-grekas. I tested it on the application that gave the error :) |
…oevgaard) This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [Cache] Only validate dbindex parameter when applicable | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #44215 | License | MIT It does not make sense to validate the path parameter when we _know_ that there can't be a dbindex. The problem with this validation is that it actually triggers when DSN looks something like: `redis://127.0.0.1:51148/` which happened to me in rare cases. Commits ------- c5e997b [Cache] Only validate dbindex parameter when applicable
Symfony version(s) affected
4.4.34
Description
When the Cache component is configured with a Redis DSN pointing to a socket (eg.
redis:///var/run/redis/redis-server.sock
), an error is thrown:Invalid Redis DSN: "redis:///var/run/redis/redis-server.sock", the "dbindex" parameter must be a number.
This is probably due to #43359 with fix #44043 and an incorrect
preg_match
in L151.How to reproduce
Possible Solution
Skip the
preg_match
check if$params['host']
is not set?Additional Context
No response
The text was updated successfully, but these errors were encountered: