php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61466 Add binary session support
Submitted: 2012-03-21 20:03 UTC Modified: 2012-03-23 16:59 UTC
From: jhansche at myyearbook dot com Assigned: andrei (profile)
Status: Closed Package: memcached (PECL)
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jhansche at myyearbook dot com
New email:
PHP Version: OS:

 

 [2012-03-21 20:03 UTC] jhansche at myyearbook dot com
Description:
------------
If an error occurs while attempting to perform a Memcached::get(), the result code will be set to RES_NOTFOUND.  However, that result is actually masking the more important error (such as connection failure, timed out, server is marked dead, etc...)

Replacing the Memcached::get() call with a Memcached::set() call results in the *correct* result code being reported.

Test script:
---------------
<?php

$mc = new Memcached();
$mc->addServer('10.2.3.4', 5555); // Server should not exist

$mc->setOption( Memcached::OPT_RETRY_TIMEOUT, 1 );

while (true)
{
  // Note how it changes if you remove either the get() call or the set() call.
  // Having only get(), results in "NOT FOUND" printed repeatedly.

  $result = $mc->get('foo');
  echo var_export( $result, true ), "; ", $mc->getResultCode( ), ': ', $mc->getResultMessage( ), "\n";

  $result = $mc->set('foo', 1, 0);
  echo var_export( $result, true ), "; ", $mc->getResultCode( ), ': ', $mc->getResultMessage( ), "\n";

  usleep(250000);
}

Expected result:
----------------
false; 3: CONNECTION FAILURE
false; 35: SERVER IS MARKED DEAD
false; 35: SERVER IS MARKED DEAD
false; 35: SERVER IS MARKED DEAD
false; 3: CONNECTION FAILURE
false; 35: SERVER IS MARKED DEAD
false; 35: SERVER IS MARKED DEAD
false; 35: SERVER IS MARKED DEAD
false; 3: CONNECTION FAILURE
...

Actual result:
--------------
false; 16: NOT FOUND
false; 35: SERVER IS MARKED DEAD
false; 16: NOT FOUND
false; 35: SERVER IS MARKED DEAD
false; 16: NOT FOUND
false; 35: SERVER IS MARKED DEAD
false; 16: NOT FOUND
false; 35: SERVER IS MARKED DEAD
...

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-23 16:59 UTC] andrei@php.net
Please re-open this issue on GitHub:

https://github.com/php-memcached-dev/php-memcached/issues
 [2012-03-23 16:59 UTC] andrei@php.net
-Summary: failure during get() resets resultCode +Summary: Add binary session support -Status: Open +Status: Closed -PHP Version: 5.3.10 +PHP Version: Irrelevant -Assigned To: +Assigned To: andrei
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Oct 28 21:01:24 2020 UTC