-
Notifications
You must be signed in to change notification settings - Fork 249
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
fix: crdb enum casting error when executing the same prepared statement twice #4448
Conversation
CodSpeed Performance ReportMerging #4448 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find odd that we don't understand the root cause about why it fails. It feels like some kind of "cached" data that is wiped by the truncate statement, but other than speculation we don't understand the root cause, and that's a little bit concerning to me as well.
Nevertheless, If the regression is fixed, I think it's worth merging.
Thanks for the fast work here! 😍 I'll flag this with the CRDB team as well, maybe one of their engineers can chime in about why this was an error. |
Here's their response:
|
Hey @AndrewSouthpaw,
Yes we can. The queries I put above in the PR description is what enables to reproduce the failure. These queries have to be executed sequentially and it will error on the second PREPARE s1 AS INSERT INTO "Test" ("id", "colors") VALUES ($1, ARRAY[$2::text]::"Color"[]);
EXECUTE s1(1, 'red');
TRUNCATE TABLE "Test" CASCADE;
EXECUTE s1(1, 'red'); I also contacted the CockroachDB team and was planning to make an issue. Just so we don't create duplicates here, have you already created one? Thanks a lot for proactively reaching out to the CockroachDB team on your own though 🙏 |
Went ahead and opened one here: cockroachdb/cockroach#114867. I had opened an internal ticket with them, but I agree it makes more sense to continue this discussion in an issue on their GitHub. Thanks so much for the quick fix! Excited to try out 5.7.0 when it's released and finally upgrade prisma 💪🏼 |
If you are eager to try it out already, |
Hey @AndrewSouthpaw, The SQL snippets you have posted suggest that you are not using the fix, so I'm a little confused. If you look at the PR description, the new casting syntax should be: VALUES (CAST($1::$text[] AS "public"."AdminRoleType"[])) But your engine is still rendering: VALUES (ARRAY[$1::text]::"public"."AdminRoleType"[]) I'm not sure if that's because you have some caching issues going on or if it's because of something else. May I ask you, if you haven't done that already, to prune/delete your node_modules and reinstall everything? It's not uncommon after client updates that some components (engine/client/cli) don't update correctly. Thank you 🙏 |
Hmm, I've tried deleting and recreating my |
Don't use |
Confirmed, that fixes the issue! Thanks for the fix 🚀 |
Overview
fixes prisma/prisma#21901
I'm honestly unsure why exactly this fixes the issue as I'm still unsure why we had this error in the first place. There seemed to be an issue only on CRDB when executing the same prepared statement twice and truncating in the middle. The error was:
The PR changes how we cast enum arrays:
Which seems to be fixing the CRDB error.