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

BACKPORT: Gen4: make sure to not merge unsharded tables from different keyspaces #9676

Merged
merged 1 commit into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/vt/vtgate/planbuilder/physical/route_planning.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ func tryMerge(

switch aRoute.RouteOpCode {
case engine.Unsharded, engine.DBA:
if aRoute.RouteOpCode == bRoute.RouteOpCode {
if aRoute.RouteOpCode == bRoute.RouteOpCode && sameKeyspace {
return merger(aRoute, bRoute)
}
case engine.EqualUnique:
Expand Down
38 changes: 38 additions & 0 deletions go/vt/vtgate/planbuilder/testdata/from_cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4532,3 +4532,41 @@ Gen4 plan same as above
]
}
}

# dont merge unsharded tables from different keyspaces
"select 1 from main.unsharded join main_2.unsharded_tab"
{
"QueryType": "SELECT",
"Original": "select 1 from main.unsharded join main_2.unsharded_tab",
"Instructions": {
"OperatorType": "Join",
"Variant": "Join",
"JoinColumnIndexes": "-1",
"TableName": "unsharded_unsharded_tab",
"Inputs": [
{
"OperatorType": "Route",
"Variant": "Unsharded",
"Keyspace": {
"Name": "main",
"Sharded": false
},
"FieldQuery": "select 1 from unsharded where 1 != 1",
"Query": "select 1 from unsharded",
"Table": "unsharded"
},
{
"OperatorType": "Route",
"Variant": "Unsharded",
"Keyspace": {
"Name": "main_2",
"Sharded": false
},
"FieldQuery": "select 1 from unsharded_tab where 1 != 1",
"Query": "select 1 from unsharded_tab",
"Table": "unsharded_tab"
}
]
}
}
Gen4 plan same as above