Skip to content
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

Route INFORMATION_SCHEMA queries #6932

Merged
merged 13 commits into from
Nov 2, 2020

Conversation

systay
Copy link
Collaborator

@systay systay commented Oct 23, 2020

For queries against INFORMATION_SCHEMA.tables, when the user is asking for a specific table that is routed, Vitess needs to look up where the table is routed, and send the query to a shard in that keyspace.

There are two predicates we look for - TABLE_SCHEMA = ? and TABLE_NAME = ?. Vitess uses the values we are searching for to know how to route the query.

Fixes #6894

systay and others added 8 commits October 22, 2020 15:41
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
…ma and table_name

Signed-off-by: Andres Taylor <andres@planetscale.com>
Normally we route queries while planning. For information_schema queries that target routed tables, we need to be able to do the routing in the engine Primitives

Signed-off-by: GuptaManan100 <manan@planetscale.com>

Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
@systay systay force-pushed the information_schema_routing_rules branch from 3c2009e to f57954b Compare October 28, 2020 12:39
…a_routing_rules

Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
@systay systay changed the title Information schema routing rules Route INFORMATION_SCHEMA queries Oct 28, 2020
@systay systay marked this pull request as ready for review October 28, 2020 13:18
When there are predicates for the table_name and table_schema, but the
table is not routed, Vitess was failing the query.

Signed-off-by: Andres Taylor <andres@planetscale.com>
Comment on lines +24 to 27
"vitess.io/vitess/go/vt/vtgate/vindexes"

"golang.org/x/sync/errgroup"
"vitess.io/vitess/go/vt/sqlparser"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a formatting issue?

Comment on lines 34 to 44
if isTableSchema {
if rut.eroute.SysTableTableSchema != nil {
return vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "two predicates for table_schema not supported")
}
rut.eroute.SysTableTableSchema = out
} else {
if rut.eroute.SysTableTableName != nil {
return vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "two predicates for table_name not supported")
}
rut.eroute.SysTableTableName = out
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the expression can contain apart from table_schema and table_name. We should check the else condition as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do handle other expressions in the WHERE clause. When we are doing pushFilter on primitiveBuilder, we look at these expressions to do the routing, but then we still add these expressions to the query:

https://github.com/vitessio/vitess/blob/master/go/vt/vtgate/planbuilder/select.go#L310

go/vt/vtgate/engine/route.go Show resolved Hide resolved
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
@systay systay merged commit 5ab4af4 into vitessio:master Nov 2, 2020
@systay systay deleted the information_schema_routing_rules branch November 2, 2020 11:22
@askdba askdba added this to the v9.0 milestone Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rails: follow routing rules in information_schema.tables
4 participants