Problem/Motivation
Trying to run on Azure, I've found that the CONFIG command is not available. Trying to open the status page will throw this (at least running Predis):
Predis\Response\ServerException: ERR unknown command `CONFIG`, with args beginning with: `get`, `maxmemory*`, inPredis\Client->onErrorResponse() (line 370 of /var/www/html/vendor/predis/
Steps to reproduce
It's actually not hard to reproduce when you have a Redis with the config under your control (e.g. with Lando). Add this line to your config file:
rename-command CONFIG ""
Then, with this config applied, visit the status page.
Proposed resolution
Catch the exception and alter the value displayed for memory accordingly.
Remaining tasks
Create patch
Review
User interface changes
The value reported for memory usage may not include a maximum value or policy (as opposed to the screen not working at all, in this situation).
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #28 | 3173988-28.patch | 2.4 KB | jonhattan |
| #26 | redis--allow_disabled_config-3173988-26.patch | 3.29 KB | renrhaf |
| #24 | redis--allow_disabled_config-3173988-24.patch | 3.37 KB | miguelds |
| #21 | redis--allow_disabled_config-3173988-21.patch | 3.37 KB | chris3proud |
| #20 | redis--allow_disabled_config-3173988-20.patch | 3.33 KB | yuraosn |
Issue fork redis-3173988
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
eelkeblokComment #3
eelkeblokHere is a first stab at a patch.
Comment #4
eelkeblokComment #6
eelkeblokNeeded a reroll, created an MR instead.
Comment #7
nitinsp commented#3 patch is not working if you applied it on latest redis module.
So above is reworked patch.
Comment #8
nitinsp commentedComment #9
eelkeblokDid you try the merge request? I think it is more up to date than patch #3.
Comment #10
kasperg commentedI have also experienced this problem on Platform.sh sites using Redis 6.0.
#9: The merge request does not apply for me either when testing with the current latest release, 8.1.5.
The patch in #7 does apply, solves the problem in my case and the code looks sound to me. I will mark this as RTBTC.
Comment #11
somersoft commentedThis patch from #7 has been rerolled so that if you have have the patch from https://www.drupal.org/project/redis/issues/2900947 it applies.
Comment #12
somersoft commentedExtended the patch from #11 so that if maxmemory policy is not returned, there is not PHP warning generated.
Comment #13
somersoft commentedFurther experiences with AWS indicate that ->info() throws an error for certain AWS ElastiCache configurations and also there is a second ->config() that needs attention too.
Comment #14
eelkeblokComment #15
t-loConfirmed the second ->config() throws an error on the default AWS elasticache configuration.
I'm working on this.
Comment #16
t-loAdded try, catch for the error thrown by the second ->config() on the reports page.
Still for if you have have the patch #49 from https://www.drupal.org/project/redis/issues/2900947 applied.
This is working for me now against a default config Elasticache redis cluster.
Comment #17
t-loComment #18
technoveltyco commented@eelkeblok @t-lo the patches provided at #16 and in the issue fork 3173988-azureaws-take-into no longer apply correctly in 1.5.0
Both patches need to be re-rolled.
Moreover, I suggest to change the use of CONFIG to INFO redis, which gives the same information and usually does not have the issue of being restricted by the hosting providers. It is also supported in both libraries, phpredis and predis.
https://github.com/phpredis/phpredis#info
https://github.com/ProgerXP/predis-doc/blob/master/Commands.md#infosection
Comment #19
technoveltyco commentedComment #20
yuraosn commentedChange patch #16
Aplied for my
Comment #21
chris3proud commentedChange patch #20
Small fix to patch #20 that gave this error
Warning: Undefined array key "used_memory_human" in Drupal\redis\Controller\ReportControllerComment #22
ericdsd commentedHi patch #21 works like a charm with AWS
Comment #23
firewaller commented#21 works for me
Comment #24
miguelds commentedChange patch #21
Small fix to patch #21 that gave me this error
Warning: Trying to access array offset on value of type bool in Drupal\redis\Controller\ReportController->overview() (line 176 of modules/contrib/redis/src/Controller/ReportController.php).Comment #25
berdirwatchdog_exception() is deprecated and removed in D11.
Comment #26
renrhafAdding a patch compatible with the 1.8 version of the module, deprecating watchdog_exception when possible.
Comment #27
abhou commentedHaving the same issue with version 1.7.0 on AWS, the patch #21 is working for me as expected.
Comment #28
jonhattanSorry for making more noise. Here's a simplified approach that rely on INFO command instead of CONFIG.
Comment #29
summit commentedpatch #26 worked for me on latest version module, thanks! greetings,
Comment #30
pene commented#21 still works like a charm with AWS Redis cache. thanks!
Client PhpRedis
Version 6.2.6
Drupal 9.5.11
Redis 8.x-1.7
Comment #31
mark-mackenzie-nexus commentedPlease can the patch at comment #28 please be added to a production release. It is necessary to allow the module to work with Azure Cache for Redis. Tested successfully from Azure App Service with Drupal 10.3.
Comment #32
mitokens commentedThanks for the fix. I can confirm the patch at #28 works for me in an Azure hosted environment with Drupal `v10.4.5` using Redis `v1.9.0` and Predis `v1.1.10`. I would be very interested in seeing it merged so I don't have to manually track this issue anymore.
Comment #33
amy_farrell commentedPatch at #28 works for me with AWS Elasticache-Redis with Drupal 10.4.5, drupal/redis 1.9.0, and predis 2.4.0.
(I also had to apply a patch from Support TLS for Predis to enable this module to provide the "tls" scheme to predis and apparently I'm following @mitokens around on this.)
Comment #34
berdirI believe this has been addressed by #3537948: Abstract info-collection RedisController to deal with special environments, if not, feel free to reopen.
Comment #35
eelkeblokI'm a little doubtful, as #3537948: Abstract info-collection RedisController to deal with special environments is still calling config() to retrieve the value. I have been running with #28 on a project for a while now, that eliminates that completely. But maybe the condition in there is enough to prevent that from happening.
Comment #36
berdirYes, but it only calls it if the information isn't already available. stats/info/config output seems to vary wildly between different, it is very much possible that while config() might not work on Azure, info() might contain that somewhere else. There also are patches here wit different approaches. if necessary we can extend the logic with a try/catch, removing it completely does not seem like a viable option.
Comment #37
eelkeblokFWIW, I can't reproduce the original problem anymore. 🙃 I had this patch for a site on Platform.sh, maybe they've changed something.
Comment #38
berdirI saw that comment and was surprised, we've been using redis on platform.sh since 2015 and never needed this.
Comment #39
eelkeblokWeird. I looked through my Git history, but no details. Only confirmation that it was for Platform.sh. I do see that the project is on Redis 6.0 and has been since we added Redis. That's not supported anymore, not sure what the status was when it was added.
Comment #40
pfrenssenReopening. I updated to Redis 8.0 on Upsun (Platform SH) and I am now getting this error. It seems this is a security recommendation from Redis when running in a hosted environment, to prevent customers from reconfiguring Redis (ref. https://redis.io/docs/latest/operate/oss_and_stack/management/security/#...).
Comment #43
pfrenssenI created a new MR because the previous one is outdated now that #3537948: Abstract info-collection RedisController to deal with special environments is in.
Thanks to the improvements made in that ticket, the fix is now very trivial.
Comment #44
milanbombschliip commentedI reviewed the MR 77 and successfully tested it on Upsun.
Comment #45
milanbombschliip commentedComment #46
berdirI'd appreciate a second MR against 2.x which moved that code, that will make it easier for me to merge this.
Comment #48
pfrenssenOpened a MR against 2.x. I did not test this out manually, the porting was quite straightforward.
Comment #49
berdirThanks.
Accessing $memory_config lines outside of the try looks a bit strange, but if we actually fall back to an empty string instead of NULL then we don't need the ?? '' fallback in the ReportController, so lets keep and change that, otherwise looks good to me.
Comment #50
pfrenssenThanks for the suggestion, both MRs are updated.
Comment #52
berdirMerged the 8.x-1.x MR but noticed that the 2.x MR seems to be missing the change in the Relay client. Maybe that bit could be in a trait or so to avoid the duplication, but off topic for this and might also have some minor differences (and will definitely have that with the cluster clients)
Comment #53
pfrenssenI missed that there is now a third client. Added the fix for this one also, sorry for keeping you busy!
Comment #54
berdirThanks, merged.