Increment operation causes connection error! (bug in server)

Bug #1067242 reported by yunhua.lee
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
libmemcached
Fix Released
High
Brian Aker

Bug Description

memcached support => enabled Version => 2.1.0
libmemcached version => 1.0.10

I set a negative or non-numeric value to a key, and then increment it.
The increment operation failed, error code and msg as following:
=========================================================
  ["errorMsg"]=>
  string(12) "CLIENT ERROR"
  ["errorNo"]=>
  int(9)
=========================================================

and more ***seriously***, the following set or get operation also failed, error code and msg as following:
=========================set operation====================
  ["errorMsg"]=>
  string(51) "SERVER HAS FAILED AND IS DISABLED UNTIL TIMED RETRY"
  ["errorNo"]=>
  int(47)
=========================get operation====================
  ["errorMsg"]=>
  string(9) "NOT FOUND"
  ["errorNo"]=>
  int(16)

phpunit test code as following( some code is simply encapsulated, not original api ):
========================================================
       //test negative number
        $value = -1;
        $result = $mc->set($keyPrefix, $key, $value);
        $this->assertTrue(Result::check($result));
        $result = $mc->get($keyPrefix, $key);
        $this->assertEquals($value, Result::getData($result));
        $result = $mc->increment($keyPrefix, $key, 1);
        //var_dump($result);
        //$this->assertTrue(Result::check($result));
        //$this->assertEquals($value + 1, Result::getData($result));

        //test non-numeric
        $value = 'str';
        $result = $mc->set($keyPrefix, $key, $value);
        var_dump($result);
        //$this->assertTrue(Result::check($result));
        $result = $mc->get($keyPrefix, $key);
        var_dump($result);
        $result = $mc->set($keyPrefix, $key, $value);
        var_dump($result);
        $result = $mc->get($keyPrefix, $key);
        var_dump($result);

I don't test decrement operation, but I guess it will have the same problem......

Related branches

yunhua.lee (yunhua-lee)
description: updated
summary: - increment operation cause connection error!
+ Increment operation causes connection error!
Revision history for this message
Brian Aker (brianaker) wrote : Re: [Bug 1067242] Re: increment operation cause connection error!
Download full text (6.2 KiB)

Thank you for the report, let me take a look and see if i can reproduce.

Sent from my Ti85

On Oct 16, 2012, at 1:10, "yunhua.lee" <email address hidden> wrote:

> ** Description changed:
>
> memcached support => enabled Version => 2.1.0
> libmemcached version => 1.0.10
>
> - I set a negative or non-numeric value to a key, and then increment it.
> - The increment operation failed, error code and msg as following:
> + I set a negative or non-numeric value to a key, and then increment it.
> + The increment operation failed, error code and msg as following:
> =========================================================
> - ["errorMsg"]=>
> - string(12) "CLIENT ERROR"
> - ["errorNo"]=>
> - int(9)
> + ["errorMsg"]=>
> + string(12) "CLIENT ERROR"
> + ["errorNo"]=>
> + int(9)
> =========================================================
>
> and more ***seriously***, the following set or get operation also failed, error code and msg as following:
> =========================set operation====================
> - ["errorMsg"]=>
> - string(51) "SERVER HAS FAILED AND IS DISABLED UNTIL TIMED RETRY"
> - ["errorNo"]=>
> - int(47)
> + ["errorMsg"]=>
> + string(51) "SERVER HAS FAILED AND IS DISABLED UNTIL TIMED RETRY"
> + ["errorNo"]=>
> + int(47)
> =========================get operation====================
> - ["errorMsg"]=>
> - string(9) "NOT FOUND"
> - ["errorNo"]=>
> - int(16)
> + ["errorMsg"]=>
> + string(9) "NOT FOUND"
> + ["errorNo"]=>
> + int(16)
>
> - phpunit test code as following( some code is simple encapsulated, not original api ):
> + phpunit test code as following( some code is simply encapsulated, not original api ):
> ========================================================
> - //test negative number
> - $value = -1;
> - $result = $mc->set($keyPrefix, $key, $value);
> - $this->assertTrue(Result::check($result));
> - $result = $mc->get($keyPrefix, $key);
> - $this->assertEquals($value, Result::getData($result));
> - $result = $mc->increment($keyPrefix, $key, 1);
> - //var_dump($result);
> - //$this->assertTrue(Result::check($result));
> - //$this->assertEquals($value + 1, Result::getData($result));
> + //test negative number
> + $value = -1;
> + $result = $mc->set($keyPrefix, $key, $value);
> + $this->assertTrue(Result::check($result));
> + $result = $mc->get($keyPrefix, $key);
> + $this->assertEquals($value, Result::getData($result));
> + $result = $mc->increment($keyPrefix, $key, 1);
> + //var_dump($result);
> + //$this->assertTrue(Result::check($result));
> + //$this->assertEquals($value + 1, Result::getData($result));
>
> - //test non-numeric
> - $value = 'str';
> - $result = $mc->set($keyPrefix, $key, $value);
> - var_dump($result);
> - //$this->assertTrue(Result::check($result));
> - $result = $mc->get($keyPrefix, $key);
> - var_dump($result);
> - $result = $mc->set($keyPrefix, $key, $value);
> - var_dump($result);
> - $result = $mc->get($keyPrefix, $...

Read more...

Revision history for this message
lisei andrei (andrei-7it) wrote : Re: Increment operation causes connection error!

Hi,

I am using the same memcached verision (2.1.0) with libmemcached 1.0.13 and I have the same connection error message when i do multiple increments. I also tested with older versions of libmemcached (1.0.12. 1.0.10, 1.0.8) with the same result.

The problem is that the issue is not easy to reproduce(at least in my environment). I didn't use any negative numbers I started the increment from 0 and i had to let all night long the test incrementing to see the errors next day in the logs.

These are the options and the way I connect to memcached servers:

      private function connect()
        {
                if ($this->_cache === NULL)
                {
                        $poolId = sha1(serialize($GLOBALS['MEMCACHED_SERVERS']));
                        $this->_cache = new Memcached($poolId);

                        if (count($this->_cache->getServerList()) == 0)
                        {
                                $this->_cache->setOption( Memcached::OPT_COMPRESSION, FALSE );
                                $this->_cache->setOption( Memcached::OPT_LIBKETAMA_COMPATIBLE, TRUE );
                                $this->_cache->setOption( Memcached::OPT_DISTRIBUTION, Memcached::DISTRIBUTION_CONSISTENT );
                                $this->_cache->setOption( Memcached::OPT_CONNECT_TIMEOUT, 500 );
                                $this->_cache->setOption( Memcached::OPT_SEND_TIMEOUT, 1000000 );
                                $this->_cache->setOption( Memcached::OPT_RECV_TIMEOUT, 1000000 );
                                $this->_cache->setOption( Memcached::OPT_POLL_TIMEOUT, 500 );
                                $this->_cache->setOption( Memcached::OPT_NO_BLOCK, TRUE );
                                $this->_cache->setOption( Memcached::OPT_SERVER_FAILURE_LIMIT, 3 );
                                $this->_cache->setOption( Memcached::OPT_BINARY_PROTOCOL, FALSE );

                                $this->_cache->addServers($GLOBALS['MEMCACHED_SERVERS']);
                        }
                }
        }

Brian Aker (brianaker)
Changed in libmemcached:
assignee: nobody → Brian Aker (brianaker)
summary: - Increment operation causes connection error!
+ Increment operation causes connection error! (bug in server)
Revision history for this message
Brian Aker (brianaker) wrote :

Calling increment or decrement on a value which is not an unsigned integer should return a value of MEMCACHED_CLIENT_ERROR. The server is throwing the actual error (i.e. this is an operation which is not supported).

Revision history for this message
Brian Aker (brianaker) wrote :

MEMCACHED_CLIENT_ERROR is not being handled correctly. Currently it is considered a fatal error, not an operation error.

A fix for this will be pushed shortly.

Brian Aker (brianaker)
Changed in libmemcached:
milestone: none → 1.0.14
importance: Undecided → High
status: New → Fix Committed
Brian Aker (brianaker)
Changed in libmemcached:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.