Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

[Prototype] More functional query killing 🎁 #202

Closed
setassociative wants to merge 3 commits intoslack-vitess-8-2021.03.03r0from
extend-rules
Closed

[Prototype] More functional query killing 🎁 #202
setassociative wants to merge 3 commits intoslack-vitess-8-2021.03.03r0from
extend-rules

Conversation

@setassociative
Copy link
Copy Markdown

@setassociative setassociative commented Mar 26, 2021

Description

This PR makes two changes:

  1. It introduces a timer-based poll of a rule config; this means we can dynamically update the query killing rules on a specific host; nominally this was already possible utilizing the topocustomrule but I kinda didn't love adding more stuff into the topo 🤷‍♂️

  2. Expands the query killer to match against leading and trailing comments

This branch is based on our 8.0 deploy; I haven't checked to see if there are upstream refactor/merge conflicts yet

TODO

  1. We could deploy this. It needs more love if we wanted to push it upstream but I wanted to stake-in-the-ground and see if folks felt is was worth doing for our build / upstream.

  2. I have a README for how QueryRules work (will drop in channel) that needs to be updated with the new stuff here + productionization roadmap.

  3. I need to update the rulsctl impl (cf Implements CLI tool for rule management vitessio/vitess#7712) to support the new comment filtering

DEMO

demo

Richard Bailey added 2 commits March 24, 2021 16:02
…o work as expected

Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
@setassociative setassociative changed the title [Prototype] More functional query killing [Prototype] More functional query killing 🎁 Mar 26, 2021
@guidoiaquinti
Copy link
Copy Markdown

Nice work! 👏 I've implemented something similar in a branch a bit ago but the query filtering/blocking was done at the vtgate layer. What do you think about that VS tablet?

@setassociative
Copy link
Copy Markdown
Author

setassociative commented Mar 26, 2021

Nice work! 👏 I've implemented something similar in a branch a bit ago but the query filtering/blocking was done at the vtgate layer. What do you think about that VS tablet?

Structurally I think this should live in the vtgates. I took the route of extend tablet filtering bc it was already there and the refactor was small enough that I'm comfortable baking this in prod with minimal testing additional testing.

I do think we actually probably could lift this approach into the gates without much effort but I'm not a fan of the current rules structure as it limits extensibility.
In my mind each filter should meet some interface so that we can build custom implementations that can work by doing something more than regexp matching if desired. That might be over engineering or it might be glorious customization opportunities 🤷. Ideally we'd also have a vtgate filter rule impl be more fully featured than this having some ability to do query re-routing (primary->replica) and have additional matching options (which keyspace, which target tablet type, etc).

That said if your branch is in a reasonable state to ship let's do it (also happy to jump in to help w/ it if that feels like the right move) -- I approached with fairly tight constraints "limit refactoring" and "a couple of afternoons timebox" and am very much not married to it. Mostly I wanted something viable as a stepping stone to whatever our long term solution was.

@setassociative setassociative changed the title [Prototype] More functional query killing 🎁 [Prototype, DRAFT] More functional query killing 🎁 Mar 26, 2021
@setassociative setassociative marked this pull request as draft March 26, 2021 18:38
@setassociative setassociative changed the title [Prototype, DRAFT] More functional query killing 🎁 [Prototype] More functional query killing 🎁 Mar 26, 2021
@guidoiaquinti
Copy link
Copy Markdown

guidoiaquinti commented Mar 29, 2021

Structurally I think this should live in the vtgates. I took the route of extend tablet filtering bc it was already there and the refactor was small enough that I'm comfortable baking this in prod with minimal testing additional testing.

👍 LGTM

I do think we actually probably could lift this approach into the gates without much effort but I'm not a fan of the current rules structure as it limits extensibility.
In my mind each filter should meet some interface so that we can build custom implementations that can work by doing something more than regexp matching if desired. That might be over engineering or it might be glorious customization opportunities 🤷. Ideally we'd also have a vtgate filter rule impl be more fully featured than this having some ability to do query re-routing (primary->replica) and have additional matching options (which keyspace, which target tablet type, etc).

That said if your branch is in a reasonable state to ship let's do it (also happy to jump in to help w/ it if that feels like the right move) -- I approached with fairly tight constraints "limit refactoring" and "a couple of afternoons timebox" and am very much not married to it. Mostly I wanted something viable as a stepping stone to whatever our long term solution was.

My branch is not in a reasonable state unfortunately. I think your approach is ✅ and we can iterate over this and maybe extend the filtering to vtgate as well in the future.

github.com/corpix/uarand v0.1.1 // indirect
github.com/cyberdelia/go-metrics-graphite v0.0.0-20161219230853-39f87cc3b432
github.com/evanphx/json-patch v4.5.0+incompatible
github.com/falun/watch v0.0.0-20200621174039-43c45ed8922d
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing against your lib ! but what about github.com/fsnotify/fsnotify ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing against your lib ! but what about github.com/fsnotify/fsnotify ?

Mostly getting it to work with my thing was essentially trivial to drop in and not the interesting part of the change. I'll swap out for a tested solution before actually baking the review

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh ugh. I remember thinking about this now

So the fancy way of doing this with notifications is that it basically is hard to operate on a file that gets created/renamed/deleted/doesn't exist. The dumb-as-rocks version i used in my library is totally fine with that since it's just polling.

I mostly don't have strong feelings about this and don't want to fight upstream about using my jank so I'm still going to try swapping out for fsnotify but that's the underlying reason why it might be preferred to do the simple thing instead.

@guidoiaquinti
Copy link
Copy Markdown

Minor comment but overall looks good to me

Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
@setassociative
Copy link
Copy Markdown
Author

This is replaced by vitessio#7784

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants