scylladb / gocql

Package gocql implements a fast and robust ScyllaDB client for the Go programming language.
https://docs.scylladb.com/stable/using-scylla/drivers/cql-drivers/scylla-go-driver.html
BSD 3-Clause "New" or "Revised" License
169 stars 47 forks source link

Simplify tokenAwareHostPolicy.Pick #197

Closed dkropachev closed 3 weeks ago

dkropachev commented 3 weeks ago

Main goal of this PR is to make tokenAwareHostPolicy.Pick code less convoluted. But there are little functional changes:

Start shuffling hosts obtained from tablets

Before this PR hosts from tablets are not being shuffled

Consider next hosts information source if current got 0 hosts

There are three host information sources: tablets, meta and tokenring, Before this PR if tables returned no hosts for given token, in certain cases code did not consider meta or tokenring. And same for meta, it did not consider tokenring. After this PR, it starts goes through tablets, meta and tokenring, if current host sources yield no hosts it proceed to next one.

Removes unnecessary locks

There was locking done on cowTabletList at t.tablets to read tablets, but since cowTabletList solves parallel access issue through COW, it is not needed.

mykaul commented 3 weeks ago

What issues does it solve? A one-line description (at least) would be appreciated.

dkropachev commented 3 weeks ago

What issues does it solve? A one-line description (at least) would be appreciated.

Added

sylwiaszunejko commented 3 weeks ago

Before this PR hosts from are not being shuffled

from tokenring? There is a missing information in the commit message and PR description

dkropachev commented 3 weeks ago

Before this PR hosts from are not being shuffled

from tokenring? There is a missing information in the commit message and PR description

Thanks, updated, from tablets