nrk/predis — Issue #59: hmset returns server error: 'Protocol error: too big bulk count string'
Author: mikemccabe
Created: 2012-02-10 07:00:39+00:00
State: open

In our production system, I'm seeing occasional failures with hmsets with large arguments. For some items, the failure rate in production is 20% or so.

> PHP Fatal error: Uncaught exception 'Predis\ServerException' with message 'ERR Protocol error: too big bulk count string' in phar:///predis_0.7.1.phar/Predis/Network/StreamConnection.php:257
> Stack trace:
> #0 phar:///predis_0.7.1.phar/Predis/Network/ConnectionBase.php(142): Predis\Network\StreamConnection->read()
> #1 phar:///predis_0.7.1.phar/Predis/Network/ConnectionBase.php(134): Predis\Network\ConnectionBase->readResponse(Object(Predis\Commands\HashSetMultiple))
> #2 phar:///predis_0.7.1.phar/Predis/Client.php(219): Predis\Network\ConnectionBase->executeCommand(Object(Predis\Commands\HashSetMultiple))
> #3 [internal function]: Predis\Client->__call('hmset', Array)
> #4 bugtest.php(42): Predis\Client->hmset('bugtest', Array)
> #5 {main}
> thrown in phar:///predis_0.7.1.phar/Predis/Network/StreamConnection.php on line 257

I've been able to reproduce it in a standalone test, but at a much lower rate - usually much less than 1%.

Test code to reproduce:
```
str_repeat('a', 74707),
'r' => str_repeat('a', 2),
'm' => str_repeat('a', 800));
$redis->hmset('bugtest', $a);
unset($redis);
}
```

Eliciting the bug seems to require a new client instance with each loop. I also couldn't reproduce the bug unless connecting to a Redis server on a different machine.

I see that the error string 'too big bulk count string' occurs in the Redis source (2.4.7), and is returned when this test in networking.c succeeds:

if (sdslen(c->querybuf) > REDIS_INLINE_MAX_SIZE) /* 1024 * 64 */

php --version:
PHP 5.3.2-1ubuntu4.7 with Suhosin-Patch (cli)