What kind of change does this PR introduce?
Aims to put read replicas to use.
What is the current behavior?
Cluster routing (the postgres.cluster.alias connection path) is broken, and doesn't work even if the cluster has one replica.
What is the new behavior?
- Which queries to route? Only adds support for simple queries in transaction mode for now.
- Actual routing logic (can be random, or round robin, not at it yet)
Additional context
We had some precedence in this very repo in https://github.com/supabase/supavisor/pull/162, which was removed in a future refactor. But it had a naive logic of routing all select statements to any random replica.
Activity
26Hi, @Snehil-Shah. It will take us some time to actually review this, since we have other priorities.
@v0idpwn Totally fine, thanks for the heads up. I'll keep iterating on this in the meantime.
@v0idpwn I have added integration tests and I think this PR is now ready for review. This only implements routing for simple queries in transaction mode to begin with. I have started working on extended queries too, but I would limit this PR to simple queries only, so we can work on easy-to-review chunks incrementally. Also, no hurries :)
This pull request is a draft
Merging is unavailable until it is marked ready for review.
@v0idpwn @mentels I have implemented a module for classifying read-safe SQL queries as of now. This will be the first step where we decide when exactly to route, before we implement the actual routing itself. Will move to that implementation once I have feedback on this and a direction for the routing.