scylladb / scylla-rust-driver

Async CQL driver for Rust, optimized for ScyllaDB!
Apache License 2.0
554 stars 94 forks source link

Metadata: don't refresh periodically by default. #1008

Open Lorak-mmk opened 2 months ago

Lorak-mmk commented 2 months ago

Currently driver refreshes metadata in 4 situations:

  1. When requested by user
  2. When receiving cql event that signals the need to refresh
  3. When re-establishing control connection
  4. Periodically, by default once every 60s. This can't be disabled (you can practically disable it by setting very long period).

Metadata may be big and so fetching it may take a lot of resources. This will be partially mitigated by https://github.com/scylladb/scylla-rust-driver/issues/595 because only necessary metadata will be fetched by default, but

  1. Users who want to download full metadata will still need to pay the full cost
  2. Even this limited metadata may be considered too expensive if downloaded unnecesarily

If cql-events are working correctly there should be no need to periodically refresh metadata. I propose to assume that they are working properly, make it possible to fully disable periodical fetching and disable it by default.

Lorak-mmk commented 2 months ago

Something I was unaware of: https://github.com/scylladb/scylla-rust-driver/issues/546 Currently driver doesn't refresh on schema change event, only on topology change event. This needs to be fixed before we can disable periodical fetching. On event we could also only download the changed parts of schema.