Skip to content

getStats() returns false when any of the servers is down #336

@jorgelzpz

Description

@jorgelzpz

Hi,

I'm having some trouble with the getStats method. When any of the servers on the pool is down, getStats returns false, so statistics from the servers that are still up cannot be read.

Is this the expected behavior? I was expecting to get at least the stats for the rest of the servers, but I'm not sure if this is like that by design.

I'm using PHP 7.1.3, Memcached 3.0.3 and libmemcached 1.0.16.

Sample code:

<?php
$m = new Memcached('example');
$m->setOptions([
        Memcached::OPT_SERVER_FAILURE_LIMIT => 2,
        Memcached::OPT_RETRY_TIMEOUT => 1,
        Memcached::OPT_DISTRIBUTION => Memcached::DISTRIBUTION_CONSISTENT,
]);

// Working server
$m->addServer('127.0.0.1', '11211', 1);
var_dump($m->getStats());
var_dump($m->getVersion());
// Everything is OK

// We add a "fake" non working server
$m->addServer('127.0.0.1', '11111', 1);

var_dump($m->getStats()); // bool(false)
echo 'Message: ' . $m->getResultMessage() . "\n"; // CONNECTION FAILURE
var_dump($m->getVersion()); // bool(false)

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions