-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rails: follow routing rules in information_schema.tables #6894
Comments
Based on the current query even if we add routing rules to information_schema if the query's where condition has In your case the selected database is |
We have a routing rule for
and rails is configured to use the mainunsharded database. Could database() be resolved for the current connection prior to routing? |
Based on #6638 it looks like the current direction is the opposite of what we need - though I'm not clear on the dangers of replacing database() with the currently selected target. It seems like this would be a more common use-case then selecting the underlying database. |
This is similar to what we have done in We can add support for routing rules when |
I think we could make the planning clever enough to recognise the situation where the query has a predicate for This will only work for equality comparisons - |
Correct, we're only looking to satisfy this function and this query, passing both a table_schema (which will always be database()) and table_name. Admittedly it does feel a bit gross to encourage the further disconnect between the contents of information_schema.tables and the ways to query it:
but this is the path of least resistance for compatibility with an ORM that expects a unified keyspace. I do wonder if in the longer term it would make sense to either make ActiveRecord aware of routing rules via a specific config (like a copy of GetRoutingRules) or even provide an alternate information_schema table (say vt_tables) with a subset of the current information that would be sufficient enough for AR to make decisions. Something with a fully resolved set of routing rules - representing the unified keyspace. |
Related issue in #6895.
Feature Description
Allow information_schema.tables to follow routing rules like SELECTs. This is more predictable than the current behaviour:
and will fix an issue with Rails where it expects to be able to run schema queries to determine data sources.
Use Case(s)
We have both unsharded and sharded tables in different keyspaces, which we can link together with routing rules in the same database, but rails expects to be able to run schema level queries on all of them identically.
The text was updated successfully, but these errors were encountered: