Redis flushdb command is run despite WP_REDIS_PREFIX, WP_REDIS_SELECTIVE_FLUSH options set #49
Replies: 3 comments
-
We don't officially support If the drop-in is activated If you want to open a PR to update this behavior you're welcome, but our team won't support |
Beta Was this translation helpful? Give feedback.
-
Understood that WP_REDIS_SELECTIVE_FLUSH is not supported. I'll probably work on adding support for doing a flushdb "equivalent" using scan as I get time. I will note that running "wp redis update-dropin" did work prior to updating the plugin to the latest version. I have a question though. In the second stack trace above, redis-cache appears to be using predis. I have WP_REDIS_CLIENT set to phpredis. |
Beta Was this translation helpful? Give feedback.
-
We use Predis to perform the "maintenance" flushing, otherwise it will use PhpRedis for all other operations.
Do you recall the error that occured? |
Beta Was this translation helpful? Give feedback.
-
Whilst upgrading our WordPress installs today with wp-cli I ran in to issues with upgrading redis-cache when updating the drop-in. The problem seems to stem from attempts to flush the Redis DB.
Description
We run a single Redis DB with prefixes set for each of our WordPress sites. Accordingly we have WP_REDIS_PREFIX and WP_REDIS_SELECTIVE_FLUSH set in wp-config.php.
On the Redis server we use ACLs for each WP site like so:
redis-01:6379> ACL GETUSER xyz.co.uk
There is something not quite right on the latest WP (6.4.1) with redis-cache v2.5.0.
The first thing I noticed was errors when trying to update the Elementor database. And the on the WP core database update. Running from the cli gave:
$ wp core update-db
RedisException: socket error on read socket in /home/xyz.co.uk/wp-content/object-cache.php:1826
Stack trace:
#0 /home/xyz.co.uk/wp-content/object-cache.php(1826): Redis->eval()
rhubarbgroup/redis-cache#1 /home/xyz.co.uk/wp-content/object-cache.php(1623): WP_Object_Cache->{closure}()
rhubarbgroup/redis-cache#2 /home/xyz.co.uk/wp-content/object-cache.php(149): WP_Object_Cache->flush()
rhubarbgroup/redis-cache#3 /home/xyz.co.uk/wp-admin/includes/upgrade.php(644): wp_cache_flush()
rhubarbgroup/redis-cache#4 phar:///usr/local/bin/wp/vendor/wp-cli/core-command/src/Core_Command.php(1319): wp_upgrade()
rhubarbgroup/redis-cache#5 [internal function]: Core_Command->update_db()
rhubarbgroup/redis-cache#6 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(100): call_user_func()
rhubarbgroup/redis-cache#7 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher{closure}()
rhubarbgroup/redis-cache#8 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(488): call_user_func()
rhubarbgroup/redis-cache#9 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(436): WP_CLI\Dispatcher\Subcommand->invoke()
rhubarbgroup/redis-cache#10 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(459): WP_CLI\Runner->run_command()
rhubarbgroup/redis-cache#11 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1284): WP_CLI\Runner->run_command_and_exit()
rhubarbgroup/redis-cache#12 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
rhubarbgroup/redis-cache#13 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(83): WP_CLI\Bootstrap\LaunchRunner->process()
rhubarbgroup/redis-cache#14 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap()
rhubarbgroup/redis-cache#15 phar:///usr/local/bin/wp/php/boot-phar.php(20): include('phar:///usr/loc...')
rhubarbgroup/redis-cache#16 /usr/local/bin/wp(4): include('phar:///usr/loc...')
rhubarbgroup/redis-cache#17 {main}
Error: Error establishing a Redis connection.
socket error on read socket
The trying update the dropin:
$ wp redis update-dropin
Predis\Response\ServerException: NOPERM this user has no permissions to run the 'flushdb' command or its subcommand in /home/xyz.co.uk/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php:384
Stack trace:
#0 /home/xyz.co.uk/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(353): Predis\Client->onErrorResponse()
rhubarbgroup/redis-cache#1 /home/xyz.co.uk/wp-content/plugins/redis-cache/dependencies/predis/predis/src/Client.php(304): Predis\Client->executeCommand()
rhubarbgroup/redis-cache#2 /home/xyz.co.uk/wp-content/plugins/redis-cache/includes/class-predis.php(171): Predis\Client->__call()
rhubarbgroup/redis-cache#3 /home/xyz.co.uk/wp-content/plugins/redis-cache/includes/class-predis.php(190): Rhubarb\RedisCache\Predis->flush()
rhubarbgroup/redis-cache#4 /home/xyz.co.uk/wp-content/plugins/redis-cache/includes/cli/class-commands.php(176): Rhubarb\RedisCache\Predis->flushOrFail()
rhubarbgroup/redis-cache#5 /home/xyz.co.uk/wp-content/plugins/redis-cache/includes/cli/class-commands.php(155): Rhubarb\RedisCache\CLI\Commands->flush_redis()
rhubarbgroup/redis-cache#6 [internal function]: Rhubarb\RedisCache\CLI\Commands->update_dropin()
rhubarbgroup/redis-cache#7 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(100): call_user_func()
rhubarbgroup/redis-cache#8 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher{closure}()
rhubarbgroup/redis-cache#9 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(488): call_user_func()
rhubarbgroup/redis-cache#10 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(436): WP_CLI\Dispatcher\Subcommand->invoke()
rhubarbgroup/redis-cache#11 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(459): WP_CLI\Runner->run_command()
rhubarbgroup/redis-cache#12 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1284): WP_CLI\Runner->run_command_and_exit()
rhubarbgroup/redis-cache#13 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
rhubarbgroup/redis-cache#14 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(83): WP_CLI\Bootstrap\LaunchRunner->process()
rhubarbgroup/redis-cache#15 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap()
rhubarbgroup/redis-cache#16 phar:///usr/local/bin/wp/php/boot-phar.php(20): include('phar:///usr/loc...')
rhubarbgroup/redis-cache#17 /usr/local/bin/wp(4): include('phar:///usr/loc...')
rhubarbgroup/redis-cache#18 {main}
Error: Object cache drop-in could not be updated. Redis server is unreachable: NOPERM this user has no permissions to run the 'flushdb' command or its subcommand
I experimented with adding the '+flushdb' ACL which went about as well as expected. The commands run without error but the entire Redis DB was flushed for all prefixes.
Expected Behavior
The redis-cache plugin should not attempt a 'flushdb' when WP_REDIS_SELECTIVE_FLUSH is set.
Actual Behavior
Actions either fail with permission errors or the whole DB is flushed.
Possible Fix
I'm not familiar enough with the codebase to suggest a fix. Sorry.
Steps to Reproduce
Additional context
I managed to get everything sorted by 1. manually copying the drop-in and 2. disabling redis-cache in order to update the Elementor database.
Environment
Beta Was this translation helpful? Give feedback.
All reactions