Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hmset returns server error: 'Protocol error: too big bulk count string' #59

Closed
mikemccabe opened this issue Feb 10, 2012 · 5 comments
Closed

Comments

@mikemccabe
Copy link

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:

<?
require_once 'predis_0.7.1.phar';
for ($i = 0; $i < 10000; $i++) {
  if ($i % 100 == 0) {
    print "$i\n";
  }
  $redis = new Predis\Client('tcp://redis_server:6379');
  $a = array('f' => 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)

@mikemccabe
Copy link
Author

I see the error more frequently with a shell loop running the following script:

<?
require_once 'predis_0.7.1.phar';
$redis = new Predis\Client('tcp://redis_server:6379');
$f = str_repeat('a', 74707);
$r = str_repeat('a', 2);
$m = str_repeat('a', 800);

$a = array('f' => $f,
           'r' => $r,
           'm' => $m);
$redis->hmset('bugtest', $a);

@nrk
Copy link
Contributor

nrk commented Feb 25, 2012

Hi @mikemccabe, sorry for the wait.

I'm still looking into this issue since I couldn't reproduce your case yet. Actually I'm not sure about what could trigger c->querybuf to grow outside the allowed size specified by REDIS_INLINE_MAX_SIZE in Redis, might end up asking @antirez for advice here.

@nrk
Copy link
Contributor

nrk commented Jul 21, 2012

It doesn't seem a bug of Predis and the same thing happens with other client libraries such as phpredis. It's most likely just the hard limit set for the maximum size of bulk values after all...

@nrk nrk closed this as completed Jul 21, 2012
@piotr-piatkowski
Copy link

Just found this bug in redis server, fix is trivial and is included with the ticket, look here: redis/redis#673

@nrk
Copy link
Contributor

nrk commented Sep 15, 2012

@piotr-piatkowski thanks for the pointer, it's definitely helpful to have it linked here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants