-
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
Bug Report: joining sharded tables with reference tables don't reroute to one in the keyspace #15777
Comments
I am not able to repro this in v19. I ran the end to end test
|
My Does I compared my situation to the test case, and it seems mostly the same, except that I have more data; I fill the reference tables with Perhaps my issue is that global routing / unspecified mode is not functioning. I don't know why. If I look at the SrvKeyspace, it all looks good. I also tried rebuilding it. What else can I look at for that? BTW, this is the
I will keep trying things in the mean time. |
I think I understand why you can't use unspecified mode. You have the same table name in |
(comment edited, because I was confusing things)
Because |
Duh, of course. Will let Rohit keep looking into this :) |
I think I have some stale information about |
I figured it out: the vschema for the diff --git a/go/test/endtoend/vtgate/queries/reference/main_test.go b/go/test/endtoend/vtgate/queries/reference/main_test.go
index 4c9440ca4f..28cc709d4b 100644
--- a/go/test/endtoend/vtgate/queries/reference/main_test.go
+++ b/go/test/endtoend/vtgate/queries/reference/main_test.go
@@ -98,6 +98,10 @@ var (
"type": "reference",
"source": "` + unshardedKeyspaceName + `.zip_detail"
}
+ "does_not_exist": {
+ "type": "reference",
+ "source": "` + unshardedKeyspaceName + `.does_not_exist"
+ }
}
}
` It also goes as I expected when I qualify the I can work around it, but it seems to me it's important to fix, because if I add extra reference tables in the future without adding to the vschema, I will create that scenario again. One extra problem though: I get a panic in vtgate when I use unspecified mode in my application now. I will discuss/report that separately. |
Without adding it to the vschema how can Vitess know about a new reference table? Maybe I am misunderstanding. Can you clarify with an example what you expect to work here? |
I see you logged the stack trace in Slack ... FYI we have another issue we are looking at, which could impact the routing of reference tables for you as well: #15770. |
Isn't that change to the test exactly that? I'm saying that if there is some reference table defined in the sharded keyspace that is not in the unsharded vschema, all reference tables stop working properly. |
Edit: See this comment for the real cause. The routing breaks for all reference tables if not all reference tables are present in the unsharded vschema.
Overview of the Issue
Reference table routing may not work as documented. If I don't explicitely name the copy of a table inside the sharded keyspace in a
SELECT ... JOIN
, it uses the currentUSE
keyspace. This results in the amount of queries scattered multiplying. When I use 'global routing' / 'unspecified mode', it also uses the source table, not the reference, with the same result.Expected result: at least for global routing mode, I expected the reference table to be used. And the documentation somewhat suggests that even when addressing the source table or having a
USE
keyspace defined, that it reroutes:But granted, perhaps I'm reading my wishes into that. It would be really great if it worked that way though, because only using unspecified mode is really hard when you're moving tables between keyspaces (as they exist in multiple keyspaces at some point, breaking the routing).
Reproduction Steps
I have these (simplified) tables:
The table
dataAttributes
is copied tosites2023
withMaterialize
, and it's defined in the VSchema forsites2023
as reference:When I run this query:
with a default
USE
oflegacy
(the defaultUSE
is the argument to themysql
command, which will affect the tabledataAttributes
), you can see it multiplies many queries to thelegacy
keyspace:But when I address the
dataAttributes
table directly insites2023
:The result is correct:
If I don't specify a default DB with
USE
, and don't fully quailfydataAttributes
, it says:I don't know at this point why my 'global routing' doesn't work, but even if I fix it by adding this vschema to
legacy
:it still picks the table from the
legacy
keyspace. To demonstrate, this is again the query with an unqualifieddataAttributes
:And I run this without a DB argument to
mysql
. It still erroneously goes tolegacy
:Binary Version
vtgate version Version: 19.0.3 (Git revision cb5464edf5d7075feae744f3580f8bc626d185aa branch 'HEAD') built on Thu Apr 4 12:18:41 UTC 2024 by runner@fv-az1543-228 using go1.22.2 linux/amd64
The text was updated successfully, but these errors were encountered: