-
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: unexpected error text type with an unknown/unsupported collation cannot be hashed
#13764
Comments
This is indeed part of the trigger. Fwiw, the usage of The core of the issue here is actually due to the usage of prepared statements. In general in MySQL prepared statements are not super useful and also with Vitess their usage is very limited. They only provide marginal benefits if you re-run the same query very often. For schema inspection queries like these, doing client side interpolation is almost always much faster and reduces the number of roundtrips significantly. This is I think also something that Prisma could consider to change as well. Nonetheless, there is really a bug here with prepared statements. I've reduced the reproduction repository to the following Go script: package main
import (
"database/sql"
"time"
_ "github.com/go-sql-driver/mysql"
)
// ...
func main() {
db, err := sql.Open("mysql", "root@tcp(127.0.0.1:15306)/commerce?interpolateParams=false")
if err != nil {
panic(err)
}
// See "Important settings" section.
db.SetConnMaxLifetime(time.Minute * 3)
db.SetMaxOpenConns(10)
db.SetMaxIdleConns(10)
_, err = db.Query(`SELECT DISTINCT
BINARY table_info.table_name AS table_name,
table_info.create_options AS create_options,
table_info.table_comment AS table_comment
FROM information_schema.tables AS table_info
JOIN information_schema.columns AS column_info
ON BINARY column_info.table_name = BINARY table_info.table_name
WHERE
table_info.table_schema = ?
AND column_info.table_schema = ?
-- Exclude views.
AND table_info.table_type = 'BASE TABLE'
ORDER BY BINARY table_info.table_name`, "commerce", "commerce")
if err != nil {
panic(err)
}
} When running this against the
@vitessio/query-serving This is probably something in the wheelhouse of you all. The reason that it seems to only trigger with prepared statements, is that somehow if we don't use those, we end up sending it straight to MySQL and avoid the problem it seems, but if we prepare it we don't (which is beyond my understanding of the query planner). When we plan it, the semantic analysis doesn't know the type of the vitess/go/vt/vtgate/engine/distinct.go Lines 122 to 133 in a30b19e
We have the https://github.com/vitessio/vitess/blob/main/go/vt/vtgate/evalengine/api_hash.go#L48-L50 We also don't have a weight string column available |
Ah ok, I'd probably say the right fix is then to change the app code, but that's not up to me really 😄. The main problem performance wise is that changing the collation on the columns means that MySQL can't use the indexes to do the join, so it performs not very optimal. These are usually queries I guess for small data sizes so it might be as big of a problem in practice. |
Aah yes, that's a good point that didn't jump to mind for me. The information schema tables should be of a manageable size, but I agree that could be a problem. The alternative solution would be re-sorting the result set on the rust side (or tweaking the comparator in our binary searches). |
Overview of the Issue
I found out that the newest image version of
vitess/vttestserver:mysql80
(same for mysql57) started to fail some tests in prisma/prisma#20608From what I understand, this is what comes out from the main branch, labeled as v18.0 (dev)
This is unexpected because only the docker image version changed, and the tests started to fail with
It looks like it might be related to the use of
BINARY
in the SQL (see reproduction repo below)Originally posted on a #shared-planetscale Slack Channel
Reproduction Steps
See minimal reproduction repository
https://github.com/Jolg42/repro-prisma-vitess-error
Binary Version
Operating System and Environment details
Log Fragments
No response
The text was updated successfully, but these errors were encountered: