Giter Site home page Giter Site logo

Comments (5)

polyfractal avatar polyfractal commented on May 20, 2024

Yes, definitely agree. I'll fix this right now.

We should be able to catch just TransportException, since all the Curl errors (OperationTimeoutException, etc) and generic node-related errors (ServerErrorResponseException, etc) are children of TransportException

I'll run some test and make sure it doesn't do anything funky. Thanks for filing this bug!

from elasticsearch-php.

damienalexandre avatar damienalexandre commented on May 20, 2024

Awesome changes, the b4e71ce commit is great too, thx!

from elasticsearch-php.

hellovic avatar hellovic commented on May 20, 2024

Sorry if I misunderstand the unit test, but if I changed the test as

public function testOneGoodOneBadHostNoException()
    {
        $params = array('hosts' => array (
            '127.0.0.1:9201',
            '127.0.0.1:9200',
        ));
        $client = new Elasticsearch\Client($params);
        $client->exists(array("index" => 'test', 'type' => 'test', 'id' => 'test'));

    }

An exception may (as host is randomly selected, only 127.0.0.1:9201 will cause error) throw

  1. Elasticsearch\Tests\ClientTest::testOneGoodOneBadHostNoException
    Elasticsearch\Common\Exceptions\Curl\CouldNotConnectToHost: Failed to connect to 127.0.0.1 port 9201: Connection refused

Two changes I have made to the
Elasticsearch\Tests\ClientTest::testOneGoodOneBadHostNoException

  1. change the first host as the one dead
  2. add $client->exists()

It seems to me that the ES client can not bypass the dead host and uses the one alive without exception throw.

from elasticsearch-php.

polyfractal avatar polyfractal commented on May 20, 2024

Good catch, thanks for the bug report!

I was bitten by the infamous PHP isset vs null issue. The retries parameter is set to null in the default configurations so that the user can see what options are available. But because the default retry value depends on the number of hosts, it has to be dynamically configured on client initialization.

So in the default config, retries is set to null. But when dynamically adjusting the value, I was only checking for isset(), so retries was not being set correctly.

Code has been updated, and I tweaked your test to force the issue. I'll tag some releases in a few minutes so that this fix becomes generally available. While I was digging around, I also found another retry bug and an optimization. Thanks!

from elasticsearch-php.

hellovic avatar hellovic commented on May 20, 2024

I see it's working now.

Thanks Zachary for the quick fix.

BTW, I got another question about dead hosts and here is link

from elasticsearch-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.