elasticsearch-php icon indicating copy to clipboard operation
elasticsearch-php copied to clipboard

StickyRoundRobinSelector starts with second host

Open mariancerny opened this issue 3 years ago • 0 comments
trafficstars

Summary of problem or feature request

When a list of multiple hosts is configured, randomizeHosts is disabled and StickyRoundRobinSelector is used the first connection goes to the second host (instead to the first one).

e.g. hosts:

  • host1
  • host2
  • host3
  • host4

Are tried in this order: host2, host3, host4, host1

Code snippet of problem

From StickyRoundRobinSelector::select():

    if ($connections[$this->current]->isAlive()) {
        return $connections[$this->current];
    }   

Because the first connection is not alive (yet), the first connection is skipped first time when select() is called.

System details

elasticsearch-php v7.10.0

mariancerny avatar Jul 29 '22 12:07 mariancerny