vitessio / vitess

Vitess is a database clustering system for horizontal scaling of MySQL.
http://vitess.io
Apache License 2.0
18.73k stars 2.1k forks source link

Question: how use Query blacklisting ?is there any examples for vitess to use Query blacklisting ? #10061

Open ronghuaihai opened 2 years ago

ronghuaihai commented 2 years ago

Question

i can not find any examples to introduce query blacklisting in official document . How to use query blacklisting ?if DBAs find slowly sql , how to blocking or forbbiden application querys that affect performance of vitess by query sql content or source ? image

mattlord commented 2 years ago

@vitessio/query-serving

mattlord commented 2 years ago

Thank you for the issue, @ronghuaihai ! You're correct, there's no documentation on this feature today. The related source code is here: https://github.com/vitessio/vitess/tree/main/go/vt/vttablet/tabletserver/rules and here: https://github.com/vitessio/vitess/tree/main/go/vt/vttablet/customrule

So I can see that this is configured on vttablets via a file containing a JSON document which can be watched for changes and auto-reloaded OR the rules can be stored in the topo server, with the contents currently loaded in memory shown at the /debug/query_rules endpoint. And we can see some samples in the test: https://github.com/vitessio/vitess/blob/main/go/vt/vttablet/tabletserver/rules/rules_test.go#L135-L144 And the key fields here: https://github.com/vitessio/vitess/blob/main/go/vt/vttablet/tabletserver/rules/rules.go#L274-L284

But we clearly need some docs. 🙂

Also, just FYI you have the ability to do this directly in the MySQL instances too: https://dev.mysql.com/doc/refman/8.0/en/rewriter-query-rewrite-plugin.html

You could rewrite the problematic queries to select "this query is not allowed" as blocked. There's also the MySQL Firewall plugin but that's not FOSS.

mhmohona commented 3 months ago

Hello @mattlord, I have searched and found Query blacklisting is not available in recent doc anymore. Thus I think this issue is not relevant anymore, isnt it?

image

mattlord commented 3 months ago

@mhmohona it's no longer mentioned in the docs, but the feature still exists w/o any docs.

mhmohona commented 3 months ago

In that case, as a doc contributor, is there anything I can do?