Error: Call to a member function hMset() on bool

Created on 28 May 2020, almost 5 years ago
Updated 18 January 2022, about 3 years ago

Problem/Motivation

When the Redis server is down, somehow, got WSOD

Error: Call to a member function hMset() on bool in Drupal\redis\Cache\PhpRedis->set() (line 97 of /var/www/html/web/modules/contrib/redis/src/Cache/PhpRedis.php)

Proposed resolution

Fall back to use drupal cache system, when Redis is down.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇨🇳China jungle Chongqing, China

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States scottsawyer Atlanta

    Just wanted to note that this patch no longer applies to 1.7.0. I am no longer experiencing a condition that causes the error, so removing the patch, and crossing fingers...

  • Status changed to Needs work about 1 year ago
  • 🇮🇳India prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan

    # 4 patch is Failed To Apply on the latest Code .

    Checking patch src/Cache/PhpRedis.php...
    Checking patch src/Cache/RedisCacheTagsChecksum.php...
    error: while searching for:
    
        // We want to differentiate between PhpRedis and Redis clients.
        if ($this->clientType === 'PhpRedis') {
          $multi = $this->client->multi();
          foreach ($keys as $key) {
            $multi->incr($key);
          }
    
    error: patch failed: src/Cache/RedisCacheTagsChecksum.php:58
    error: src/Cache/RedisCacheTagsChecksum.php: patch does not apply
    Checking patch src/Lock/PhpRedis.php...
    Checking patch src/Queue/ReliablePhpRedis.php...
    
  • 🇮🇳India prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan

    Updated The Patch as per latest code.

  • Status changed to Needs review about 1 year ago
  • 🇮🇳India prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan
  • 🇧🇬Bulgaria alexrayu

    Sadly patch from #8 did not apply for me upgrading to 1.8.0
    Attaching the patch for 1.8.0.

  • 🇳🇱Netherlands casey

    https://github.com/phpredis/phpredis?tab=readme-ov-file#multi-exec-discard

    Redis::MULTI or Redis::PIPELINE. Defaults to Redis::MULTI. A Redis::MULTI block of commands runs as a single transaction; a Redis::PIPELINE block is simply transmitted faster to the server, but without any guarantee of atomicity.

    I guess we want to keep atomicity. Instead of switching to Redis::PIPELINE, a check should be added on the return value of the multi() call.

  • 🇨🇭Switzerland berdir Switzerland

    This needs to be a merge request.

  • Pipeline finished with Failed
    4 months ago
    Total: 275s
    #373632
  • 🇮🇳India prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan

    @berdir Added the Mr From the #10. Please Review

  • 🇨🇭Switzerland berdir Switzerland

    Tests are failing with relay because that constant then doesn't exist.

  • 🇫🇷France MacSim

    I also met this error on a prod instance where redis was hosted on another virtual machine and running in protected mode.

    $ drush cr
    PHP Fatal error:  Uncaught Error: Call to a member function hMset() on bool in /var/www/html/web/modules/contrib/redis/src/Cache/PhpRedis.php:97
    $ nc {redis_ip} 6379
    -DENIED Redis is running in protected mode because protected mode is enabled and no password is set for the default user. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions:
    1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent.
    2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server.
    3) If you started the server manually just for testing, restart it with the '--protected-mode no' option.
    4) Set up an authentication password for the default user. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
    

    Just in case some people would meet this use case ;)

Production build 0.71.5 2024