rhubarbgroup / redis-cache

A persistent object cache backend for WordPress powered by Redis. Supports Predis, PhpRedis, Relay, replication, sentinels, clustering and WP-CLI.
https://wordpress.org/plugins/redis-cache/
GNU General Public License v3.0
425 stars 148 forks source link

Command _MASTERS is not a registered Redis command when fluash cache on cli #527

Closed Albvadi closed 2 months ago

Albvadi commented 3 months ago

Description

Hi, your worst nightmare here... :upside_down_face: According to #514, the enable command now is working well, but I´m trying to flush the cache Redis from command cli, and I get the following error:

[apache@myserver /opt/apache/htdocs/wordpress-site]$ php wp-cli.phar redis update-dropin
Predis\ClientException: Command `_MASTERS` is not a registered Redis command. in /opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Command/Factory.php:67
Stack trace:
#0 /opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(313): Predis\Command\Factory->create('_MASTERS', Array)
#1 /opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(304): Predis\Client->createCommand('_masters', Array)
#2 /opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache/includes/class-predis.php(164): Predis\Client->__call('_masters', Array)
#3 /opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache/includes/class-predis.php(198): Rhubarb\RedisCache\Predis->flush(true)
#4 /opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache/includes/cli/class-commands.php(176): Rhubarb\RedisCache\Predis->flushOrFail()
#5 /opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache/includes/cli/class-commands.php(155): Rhubarb\RedisCache\CLI\Commands->flush_redis()
#6 [internal function]: Rhubarb\RedisCache\CLI\Commands->update_dropin(Array, Array)
#7 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(100): call_user_func(Array, Array, Array)
#8 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}(Array, Array)
#9 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(491): call_user_func(Object(Closure), Array, Array)
#10 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(431): WP_CLI\Dispatcher\Subcommand->invoke(Array, Array, Array)
#11 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(454): WP_CLI\Runner->run_command(Array, Array)
#12 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1269): WP_CLI\Runner->run_command_and_exit()
#13 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
#14 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/bootstrap.php(83): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState))
#15 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap()
#16 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/php/boot-phar.php(20): include('phar:///opt/htt...')
#17 /opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar(4): include('phar:///opt/htt...')
#18 {main}
Error: El dependiente de caché no se pudo actualizar. El servidor Redis no está disponible: Command `_MASTERS` is not a registered Redis command.

If I flush the cache from Wordpress admin area, is flushed correctly.

Expected Behavior

Flush cache Redis from command cli

Actual Behavior

Exception

Steps to Reproduce

  1. Install new wordpress site and add the plugin
  2. Activate the plugin
  3. Enable fthe plugin (from command cli or wp admin area)
  4. Try to flush cache from command cli

Environment

define('WP_REDIS_CLUSTER', [ 'tcp://redisint1.dev:6379?alias=redisint1', 'tcp://redisint2.dev:6379?alias=redisint2', 'tcp://redisint3.dev:6379?alias=redisint3' ]);



Thank you!
tillkruss commented 3 months ago

@yatsukhnenko Can you take a look at this?

tillkruss commented 3 months ago

Try setting define('WP_REDIS_CLIENT', 'phpredis');

Albvadi commented 3 months ago

Hello, sorry for the late response.

While testing, now I also get an error when enabling. I really don't know why a few days ago it didn't give me an error and now it does, I'm not very clear if it is my problem that I have changed some configuration or it is the library's problem, that some inconsistent configuration has been left.

Likewise, I have configured the client and re-issued the commands with the following result.

php wp-cli redis status

Status: No activado
Client: phpredis
Drop-in: Not installed
Disabled: No
PhpRedis: 5.3.4
Relay: Not loaded
Predis: Not loaded
Credis: Not loaded
PHP Version: 7.4.30
Plugin Version: 2.5.2
Redis Version: Unknown
Multisite: No
Metrics: Disabled
Metrics recorded: 0
Filesystem: Writable
WP_REDIS_CLIENT: "phpredis"
WP_REDIS_SCHEME: "tcp"
WP_REDIS_CLUSTER: [
    "tcp://redisint1.dev:6379?alias=redisint1",
    "tcp://redisint2.dev:6379?alias=redisint2",
    "tcp://redisint3.dev:6379?alias=redisint3"
]
WP_CACHE_KEY_SALT: "wordpress_site_des"
WP_REDIS_PLUGIN_PATH: "/opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache"
Drop-ins: []

php wp-cli.phar redis enable

Predis\ClientException: Command `_MASTERS` is not a registered Redis command. in /opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Command/Factory.php:67
Stack trace:
#0 /opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(313): Predis\Command\Factory->create()
#1 /opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(304): Predis\Client->createCommand()
#2 /opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache/includes/class-predis.php(164): Predis\Client->__call()
#3 /opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache/includes/class-predis.php(198): Rhubarb\RedisCache\Predis->flush()
#4 /opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache/includes/cli/class-commands.php(176): Rhubarb\RedisCache\Predis->flushOrFail()
#5 /opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache/includes/cli/class-commands.php(63): Rhubarb\RedisCache\CLI\Commands->flush_redis()
#6 [internal function]: Rhubarb\RedisCache\CLI\Commands->enable()
#7 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(100): call_user_func()
#8 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}()
#9 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(491): call_user_func()
#10 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(431): WP_CLI\Dispatcher\Subcommand->invoke()
#11 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(454): WP_CLI\Runner->run_command()
#12 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1269): WP_CLI\Runner->run_command_and_exit()
#13 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
#14 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/bootstrap.php(83): WP_CLI\Bootstrap\LaunchRunner->process()
#15 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap()
#16 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/php/boot-phar.php(20): include('phar:///opt/htt...')
#17 /opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar(4): include('phar:///opt/htt...')
#18 {main}
Error: No se pudo activar la caché de objetos. El servidor Redis no está disponible: Command `_MASTERS` is not a registered Redis command.

php wp-cli redis status (after enabled from wordpress dashboard)

Status: Conectado
Client: PhpRedis (v5.3.4)
Drop-in: Valid
Disabled: No
Ping: 1
Errors: []
PhpRedis: 5.3.4
Relay: Not loaded
Predis: Not loaded
Credis: Not loaded
PHP Version: 7.4.30
Plugin Version: 2.5.2
Redis Version: 5.0.8
Multisite: No
Metrics: Enabled
Metrics recorded: 5
Filesystem: Writable
Global Prefix: "wp_"
Blog Prefix: "wp_"
Timeout: 1
Read Timeout: 1
Retry Interval:
WP_REDIS_CLIENT: "phpredis"
WP_REDIS_SCHEME: "tcp"
WP_REDIS_CLUSTER: [
    "tcp://redisint1.dev:6379?alias=redisint1",
    "tcp://redisint2.dev:6379?alias=redisint2",
    "tcp://redisint3.dev:6379?alias=redisint3"
]
WP_REDIS_PREFIX: "wordpress_site_des"
WP_CACHE_KEY_SALT: "wordpress_site_des"
WP_REDIS_PLUGIN_PATH: "/opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache"
Global Groups: [
    "blog-details",
    "blog-id-cache",
    "blog-lookup",
    "global-posts",
    "networks",
    "rss",
    "sites",
    "site-details",
    "site-lookup",
    "site-options",
    "site-transient",
    "users",
    "useremail",
    "userlogins",
    "usermeta",
    "user_meta",
    "userslugs",
    "redis-cache",
    "blog_meta",
    "network-queries",
    "site-queries",
    "theme_files",
    "translation_files",
    "user-queries"
]
Ignored Groups: [
    "counts",
    "plugins",
    "theme_json",
    "themes"
]
Unflushable Groups: []
Groups Types: {
    "blog-details": "global",
    "blog-id-cache": "global",
    "blog-lookup": "global",
    "global-posts": "global",
    "networks": "global",
    "rss": "global",
    "sites": "global",
    "site-details": "global",
    "site-lookup": "global",
    "site-options": "global",
    "site-transient": "global",
    "users": "global",
    "useremail": "global",
    "userlogins": "global",
    "usermeta": "global",
    "user_meta": "global",
    "userslugs": "global",
    "redis-cache": "global",
    "blog_meta": "global",
    "network-queries": "global",
    "site-queries": "global",
    "theme_files": "global",
    "translation_files": "global",
    "user-queries": "global",
    "counts": "ignored",
    "plugins": "ignored",
    "theme_json": "ignored",
    "themes": "ignored"
}
Drop-ins: [
    "Redis Object Cache Drop-In v2.5.2 by Till Krüss"
]

php wp-cli redis update-dropin

PHP Warning:  chmod(): Operation not permitted in /opt/http-2.4.48/htdocs/wordpress-site/wp-admin/includes/class-wp-filesystem-direct.php on line 173
Warning: chmod(): Operation not permitted in /opt/http-2.4.48/htdocs/wordpress-site/wp-admin/includes/class-wp-filesystem-direct.php on line 173
Predis\ClientException: Command `_MASTERS` is not a registered Redis command. in /opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Command/Factory.php:67
Stack trace:
#0 /opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(313): Predis\Command\Factory->create()
#1 /opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(304): Predis\Client->createCommand()
#2 /opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache/includes/class-predis.php(164): Predis\Client->__call()
#3 /opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache/includes/class-predis.php(198): Rhubarb\RedisCache\Predis->flush()
#4 /opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache/includes/cli/class-commands.php(176): Rhubarb\RedisCache\Predis->flushOrFail()
#5 /opt/http-2.4.48/htdocs/wordpress-site/wp-content/plugins/redis-cache/includes/cli/class-commands.php(155): Rhubarb\RedisCache\CLI\Commands->flush_redis()
#6 [internal function]: Rhubarb\RedisCache\CLI\Commands->update_dropin()
#7 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(100): call_user_func()
#8 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}()
#9 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(491): call_user_func()
#10 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(431): WP_CLI\Dispatcher\Subcommand->invoke()
#11 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(454): WP_CLI\Runner->run_command()
#12 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1269): WP_CLI\Runner->run_command_and_exit()
#13 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
#14 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/bootstrap.php(83): WP_CLI\Bootstrap\LaunchRunner->process()
#15 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap()
#16 phar:///opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar/php/boot-phar.php(20): include('phar:///opt/htt...')
#17 /opt/http-2.4.48/htdocs/wordpress-site/wp-cli.phar(4): include('phar:///opt/htt...')
#18 {main}
Error: El dependiente de caché no se pudo actualizar. El servidor Redis no está disponible: Command `_MASTERS` is not a registered Redis command.
yatsukhnenko commented 3 months ago

@Albvadi could you test fix https://github.com/rhubarbgroup/redis-cache/pull/529?

Irytacja commented 2 months ago

Hi @yatsukhnenko any idea when you guys planning on releasing it? i have same issues while trying to wp redis enable even tho in wp-config.php im using phpredis define('WP_REDIS_CLIENT','phpredis');

tillkruss commented 2 months ago

This week 👍