Following issue: on a testing machine, we had the module in the latest 2.x version, everything was running fine. Using latest Drupal and latest Predis.

For testing purposes, I installed 3.2. Then I experienced an error saying:

Original
Predis\Response\ServerException: ERR Protocol error: invalid bulk length in Predis\Client->onErrorResponse() (line 367 of sites/all/libraries/predis/lib/Predis/Client.php).

Additional
Predis\Connection\ConnectionException: Error while reading line from the server. [tcp://localhost:6379] in Predis\Connection\AbstractConnection->onConnectionError() (line 146 of sites/all/libraries/predis/lib/Predis/Connection/AbstractConnection.php).

I stepped through the code and found the following issue: Investigating sites/all/libraries/predis/lib/Redis/Cache/Predis.php and looking at functions deleteByPrefix(), flush() and flushVolatile(). The call always looks like

$client->eval(self::EVAL_DELETE_{VOLATILE|PREFIX}, array(<some parameter> . '*'));

Now looking at the Predis provided implementation of "eval" as well as looking through the Redis docs. It states that it needs a number of arguments and then the arguments themselfs. When I googled for the error, I came accross this Predis issue https://github.com/nrk/predis/issues/88 stating that you cannot pass an array.

So what I did is changing the call signature to

$client->eval(self::EVAL_DELETE_{VOLATILE|PREFIX}, 0, <some parameter> . '*') ;

Note the "0" as well as the removal of array() for the argument itself. This seems to fix all issues I had. I am able to properly flush the caches, everything gets written/read again and I don't see any errors that seem to indicate any issues with that fix.

I'm not sure why this has happened to me or why nobody else has the issues. Either did I do something wrong with the setup or did I miss some configuration variable somewhere?

If this issue gets confirmed, I'm happy to create a patch.

Comments

drcolossos’s picture

Issue summary: View changes
drcolossos’s picture

Title: invalid bulk length » Invalid bulk length due to possbile wrong function call
pounard’s picture

Thanks for reporting!

I need to be able to reproduce it, I will setup a Predis-based Drupal instance to test it; it seems you actually found a real bug.

Please note that I didn't fully tested the Predis backend on the 3.x release yet, I will do it as soon as I can.

pounard’s picture

Assigned: Unassigned » pounard
drcolossos’s picture

FYI, we have this now in production without any problems (Redis 2.8). We chose the 3.x branch since we consider proper flushing of the cache keys a must. We didn't ran into any problems so far with above mentioned fix.

pounard’s picture

Ok, so I need to find a way to preproduce it than I will apply your patch, thanks for the feedback.

mikl’s picture

I can reproduce this, too. Using version 3.3 of this module, Redis 3.0.0 and Predis v1.0.0.

pounard’s picture

Status: Active » Fixed

@DrColossos, Ok, long time no see, I'm sorry.

I just refactored all the unit tests and started to test once again with Predis since that it seems that a lot of people are using it, and I found out by reading your issue summary that you managed to find the source of the bug I couldn't find the whole afternoon!

You saved my day! I can definitely credit you in the commit message. Thanks a lot.

  • Pierre.R committed 53f4e89 on 7.x-3.x authored by DrColossos
    Issue #2453065 by DrColossos: Invalid bulk length due to possbile wrong...
pounard’s picture

Just as a side note, there is still one last remaining test failing with Predis, but this is not linked to this issue anymore, if you encounter the bug please file a new issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.