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

sql: Vitess cannot support Grafana 10+ CTEs #13632

Closed
derekperkins opened this issue Jul 27, 2023 · 10 comments
Closed

sql: Vitess cannot support Grafana 10+ CTEs #13632

derekperkins opened this issue Jul 27, 2023 · 10 comments

Comments

@derekperkins
Copy link
Member

We've used Vitess for Grafana persistence for several years, but after upgrading to v10, certain functionality including dashboard list/search fails due to usage of CTEs. This is a known issue, I just wanted to call this out specifically since we have tracked compatibility with major projects in the past. Feel free to close if it isn't useful, but it'll at least help anyone searching.

"Search failed" error="Error 1235: unsupported: with expression in select statement"

Related issues:

@systay
Copy link
Collaborator

systay commented Dec 13, 2023

@derekperkins Any chance you could share the query that is breaking vtgate?

@derekperkins
Copy link
Member Author

There's a test here for recursive queries
https://github.com/grafana/grafana/blob/main/pkg/services/sqlstore/sqlstore.go#L363-L392

And a comment about how it relates to Vitess
grafana/grafana#73725 (comment)

@derekperkins
Copy link
Member Author

I submitted a PR based on that comment, hopefully they accept it and it works

@derekperkins
Copy link
Member Author

derekperkins commented Mar 12, 2024

Still trying to get this to work. There has been no movement on the original PR.

This has been longer coming, but go-sql-driver/mysql just released a new version that supports a / in the db name. I also have a PR into Grafana to use that new dependency, so that I can use shard targeting to allow the recursive queries to execute, which should be more reliable long-term.

@harshit-gangal
Copy link
Member

Now that Vitess have CTE support, do you want to try it?

@derekperkins
Copy link
Member Author

Planning on rolling out v21 this weekend, then I'll try it

@derekperkins
Copy link
Member Author

derekperkins commented Nov 6, 2024

v21 actually made things worse. Previously, Grafana detected that recursive CTEs weren't supported and would fallback to other mechanisms. Now that Vitess says that they are supported, it uses the regular recursive SQL, but that fails. Here is the vttablet log. This runs on initial startup and for every search, so it makes grafana unusable.

tabletserver.go:1587] Unknown column 'n' in 'field list' (errno 1054) (sqlstate 42S22) (CallerID: grafanaAdmin): Sql: "with recursive cte as (select :vtg1 /* INT64 */ from dual union all select n + :vtg1 /* INT64 */ from cte where n < :n /* INT64 */) select n from cte", BindVars: {#maxLimit: "type:INT64 value:\"50001\""n: "type:INT64 value:\"2\""vtg1: "type:INT64 value:\"1\""}

@deepthi
Copy link
Member

deepthi commented Nov 6, 2024

That's a bummer. Can you create a separate issue with the query so that we can try to fix it?

@systay
Copy link
Collaborator

systay commented Nov 12, 2024

@derekperkins wdyt - can we close this issue now?

@derekperkins
Copy link
Member Author

Sure. I'll open it again once this is available in a release if there are any other issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants