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

Tablets lack of pulling all tables #199

Closed dkropachev closed 3 weeks ago

dkropachev commented 3 weeks ago

Problem

Currently we fill in tables information only from prepared statement respose: https://github.com/scylladb/gocql/blob/dce12c13e8f4700bd53f1bdef30bb7d95d38efdd/conn.go#L1519

Which means that Session.getTablets does not have all the tablet information https://github.com/scylladb/gocql/blob/dce12c13e8f4700bd53f1bdef30bb7d95d38efdd/session.go#L612

Which means that schemaDescriber and scyllaConnPicker are using only partial tablet data and therefore do not yield correct results.

Solution

Start pulling system.tablet on topology change events and at the startup.

mykaul commented 3 weeks ago

I'm not sure, but it may have been done in purpose - we did not want to pull the data for 100,000 tablets every time. @sylwiaszunejko ?

dkropachev commented 3 weeks ago

Without it driver can't properly pick connection for range queries and very first query to the range is being made to a wrong shard. We can limit it to a particular keyspace+table.

mykaul commented 3 weeks ago

Without it driver can't properly pick connection for range queries and very first query to the range is being made to a wrong shard. We can limit it to a particular keyspace+table.

Yes, the first query will be wrong, but it's better than consuming gozillion of tablets worth of information. I agree we can limit it to a specific ks+tbl. I thought we did or we discussed doing, but does it matter if it's after the 1st query or before it?

dkropachev commented 3 weeks ago

Yes, the first query will be wrong, but it's better than consuming gozillion of tablets worth of information. I agree we can limit it to a specific ks+tbl. I thought we did or we discussed doing, but does it matter if it's after the 1st query or before it?

it would be good to have it correctly routed, but in almost all cases, that I can image. it is not critical.

sylwiaszunejko commented 3 weeks ago

@dkropachev As @mykaul said, it was a design decision to not pull system.tablets. We considered multiple approaches of getting tablet info to the drivers e.g. periodically pulling all of the tablets info, new type of an event with tablet change and lazy approach. The decision was made to go with lazy approach and send tablet info to the driver if query was not routed correctly.

dkropachev commented 3 weeks ago

So, I close it, as it works as designed

mykaul commented 3 weeks ago

We may wish to document this somewhere, if it's not already.