php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68616 memcache call fallback only once
Submitted: 2014-12-17 10:35 UTC Modified: -
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:-1 (-100.0%)
From: tom916 at qq dot com Assigned:
Status: Open Package: memcache (PECL)
PHP Version: 5.5.19 OS: Linux app10-116 3.8.0-34-generic
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2014-12-17 10:35 UTC] tom916 at qq dot com
Description:
------------
memcache call fallback only once 

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

function fail(){
    print_r(func_get_args());
}



function foo(){
    $mem = new Memcache();
    $server = array(
        'host'=>'8.8.8.8',
        'port'=>'11211',
        'persistent'=>1
    );


    $mem->addServer($server['host'],$server['port'],$server['persistent'],1,1,15,true,'fail');
    $mem->get('xx');
}


foo();
echo "over 1\n";
foo();
echo "over 2\n";

Expected result:
----------------
Array
(
    [0] => 8.8.8.8
    [1] => 11211
    [2] => 0
    [3] => Connection timed out
    [4] => 110
)
over 1
Array
(
    [0] => 8.8.8.8
    [1] => 11211
    [2] => 0
    [3] => Connection timed out
    [4] => 110
)
over 2

Actual result:
--------------
Array
(
    [0] => 8.8.8.8
    [1] => 11211
    [2] => 0
    [3] => Connection timed out
    [4] => 110
)
over 1
over 2

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-28 00:46 UTC] chuanm at gmail dot com
This may not be a bug.

The memcache library should cache the failed server list and won't retry it in 15 seconds because retry_interval is set to 15 seconds while calling Memcache::addServer() (http://php.net/manual/en/memcache.addserver.php). When I changed that line to force memcache to always try the failed server (by passing 0 seconds to retry_interval), it works as expected.

  $mem->addServer($server['host'],$server['port'],$server['persistent'],1,1,0,true,'fail');



Actual result:
---------------
Array
(
    [0] => 8.8.8.8
    [1] => 11211
    [2] => 0
    [3] => Connection timed out
    [4] => 110
)
Array
(
    [0] => 8.8.8.8
    [1] => 11211
    [2] => 0
    [3] => Connection timed out
    [4] => 110
)
over 1
Array
(
    [0] => 8.8.8.8
    [1] => 11211
    [2] => 0
    [3] => Connection timed out
    [4] => 110
)
Array
(
    [0] => 8.8.8.8
    [1] => 11211
    [2] => 0
    [3] => Connection timed out
    [4] => 110
)
over 2
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Dec 07 11:01:24 2019 UTC