-
Notifications
You must be signed in to change notification settings - Fork 326
single get() failover doesnt work! #154
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
Comments
I just tested with libmemcached 1.0.18 and I cannot reproduce this issue |
nope. just updated to 1.0.18 and the Problem still exists. please be sure you try a key for non-working-host. this is a full working example. if you change Hosts you have to check if you have the right key for non_working_host: $a = new Memcached(); $a->addServer('localhost', 11211); print "be sure you use a key for non_working_host: ".$a->getServerByKey ('key_on_non_working_host')['port']." : should be 11222 \n\n"; $t1 = $a->set('key_on_non_working_host', 1); var_dump($t1); // = TRUE -> WORKS! value stored on working_host (=localhost) // Setup new connection $b->addServer('localhost', 11211); $t1 = $b->get('key_on_non_working_host'); // we have to do AFTER first false-get(): $b->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE,true); // THIS is needed! without that we get at the following get() FALSE and Error 35! can you confirm that we should get a result with the first get() call and without the second setoption(OPT_LIBKETAMA_COMPATIBLE)+get() ? |
Hi @mkoppanen @stangl I think I'm having the same issue. How did you work around that? |
Closing. This is the intentional behavior, although the documentation could be better. Here's a good blog post that goes into detail, and I'll excerpt a relevant part:
[emphasis added] The auto-failover in libmemcached does work, but there are internal timeouts. The distribution of keys is not immediately recalculated after a single failed get to a backend memcached. To do so would trigger horrible flapping, because failures can and do occur randomly on a heavily loaded server network. Also with some more details: |
Hi |
php-memcached: 2.2.0
libmemcached: 1.0.16
$a = new Memcached();
$a->setOption(Memcached::OPT_BINARY_PROTOCOL,true);
$a->setOption(Memcached::OPT_REMOVE_FAILED_SERVERS, true);
$a->setOption(Memcached::OPT_DISTRIBUTION,Memcached::DISTRIBUTION_CONSISTENT);
$a->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE,true);
$a->addServer('working_host', 11211);
$a->addServer('non_working_host', 11211);
$a->set('key_on_non_working_host', 1); // = TRUE -> WORKS! value stored on working_host
// Setup new connection
$b = new Memcached();
$b->setOption(Memcached::OPT_BINARY_PROTOCOL,true);
$b->setOption(Memcached::OPT_REMOVE_FAILED_SERVERS, true);
$b->setOption(Memcached::OPT_DISTRIBUTION,Memcached::DISTRIBUTION_CONSISTENT);
$b->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE,true);
$b->addServer('working_host', 11211);
$b->addServer('non_working_host', 11211);
$b->get('key_on_non_working_host'); // = FALSE -> DOENST WORK!
// we have to do AFTER first false-get():
$b->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE,true);
$b->get('key_on_non_working_host'); // = TRUE -> SECOND CALL NOW WORKS!
this failure doenst happen if the inital set() and the get() are called in same connection. then it seems the system "remember" from set() that the non_working_host istn available.
The text was updated successfully, but these errors were encountered: