-
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
RFC: surface warnings and/or errors for unknown vindex params #13041
Comments
Regarding Vindex Warnings. type VindexWarning interface {
func VindexWarnings() []string
} If I have understood correctly, regarding supporting feature #12413. I think we can change the params from |
Hey @harshit-gangal
OK that makes sense! I'll rework option 1 to do that.
Yeah using |
@harshit-gangal made those updates |
I think Option 1 is good as it does not change user behaviour and gives the option to log warnings to indicate the issue with the vindex setup. |
@harshit-gangal great, I'll get started on updating the PR to match option 1. One thing about option 1 is that it will require Vindexes to store their either their input params or their warnings, e.g.:
In theory this will increase the amount of memory used by Vindexes compared to if they just returned warnings during Vindex creation phase. I assume you already thought of this and are not concerned, but just adding this comment in case you or anyone else would have concerns about that. |
You can check and return at that point in time as this is not something will be used repeatedly |
@harshit-gangal even if this is not used repeatedly, Vindexes will be carrying extra memory from holding param errors:
We can't check and return an error in |
I say we do not need to store the warnings , we already have the passed in params. |
Hey @harshit-gangal I can do that but I think that is likely to use more memory than storing the warnings. If we pass in 10 params and they are all valid, then no warnings are generated and storing the params on the Vindex is just wasted memory. If we store the warnings, if all the passed in params are valid then we will use less memory. |
We are already storing the parameters. The only way to make vindex know what to do with the passed in params. |
I see what you mean, we use the parameters and store transformed values. Today we store any issue with a keyspace in
should we continue to use this and add warnings here? |
Also, do we really need []error store or a single aggregated error is enough? |
Hey @harshit-gangal even before we think about storing values on In terms of what we store on If you think that it makes more sense to store errors in
I think it would be more useful to store these as separate |
Alternately the interface could be something like:
And let callers decide whether they qualify as errors or not. |
This sounds reasonable. We can store the unknown parameters at the vindex level. The memory will increase only if there are unknown parameters passed so this is acceptable. |
@harshit-gangal OK have updated the RFC to incorporate the convo up to this point and updated #12951 to match. |
@maxenglander It's great to see these changes. I noticed that #13322 added warnings to the Vtctl |
@brendar good idea! Added to the task list in the issue description. I'll take a crack at it if someone else doesn't beat me to it. |
Oops, didn't mean to close this, one item left.
@brendar the |
Introduction
Vindexes allow Vindex-specific parameters to be passed via the
params
field. For example:Currently it is the responsibility of each Vindex to validate its own params. Some Vindexes do strict validation of params, while other Vindexes do very little param validation. All Vindexes happily accept unknown params.
Problem
For the most part, there aren't any problems with this. If a user forgets to pass in a required param, the Vindex will complain or fail, and the user will know about it.
However, if the user passes in an optional param, but makes a typo in the param name, most Vindexes will happily accept the typo param, and do nothing with it.
In some cases that silent ignore can be a problem. For example, the
lookup
Vindex family supports a number of performance-impacting parameters, such asread_lock
. If a user tries to setraed_lock
(notice typo) tonone
, expecting that this will reduce lock contention, they will be in for an unpleasant surprise during the next traffic spike.Proposal
This RFC proposes updating Vitess to warn users when they pass in unknown parameters to the Vindexes. The warnings can be surfaced to users via logs and metrics.
Importantly, warnings will be backwards-compatible, and it will be the responsibility of users to monitor logs and metrics for these warnings, and take additional corrective actions.
Optionally, a user can opt in to stricter param validation via a flag such as
--vschema-strict
, which will escalate these warnings to errors. A user might choose to opt in to--vschema-strict
in development and staging environments, but leave the default behavior on in production.Options
Some ways this could be implemented.
Have vindexes optionally report warnings
Introduce a
ParamValidating
interface like:Then update the logic of individual Vindexes to return non-empty
UnknownParams()
when any parameters passed to the Vindex during Vindex creation was unknown.Update various parts of Vitess codebase to look for unknown params in Vindexes, and emit logs and metrics. For example:
vtgate.(*VschemaStats)
to export warnings in its HTTP output.vtgate_vschema_vindex_unknown_param_count
stat fromvtgate.(*VSchemaManager)
.ApplyVSchema
to return warnings in response, while continuing to accept the input if there aren't any errors.Pros
Cons
Add per-Vindex VSchema params
Currently all Vindexes that accept parameters do so via the
params
field, which is not really strongly typed.We can introduce stronger typing by having each Vindex which declares params register strongly typed params in the VSchema protobuf definition.
How this might look in the protobuf definition.
A user could opt in to stronger Vindex param validation by specifying
lookup_params
in the VSchema:Notice how in the VSchema above
autocommit
is a boolean, instead of a string with the word"true"
.Initially we would support both
params
as well aslookup_params
.lookup_params
would take precedence when present, and fall back toparams
when null.We could choose to support both
params
as well as{type}_params
indefinitely, or else eventually deprecate and removeparams
. The former would give users to option of choosing between loose param validation or strict param validation by using eitherparams
or{type}_params
.Pros
Cons
params
in favor of{type}_params
, that would be a big change to force on the community.params
and{type}_params
indefinitely, that is a burden for maintainers to support.params
field indefinitely for those out-of-tree plugins.read_lock
field from the protobuf definition, in order to upgrade users would need to first remove this field from their VSchema, and then upgrade their VT* components.Recommendation
I really like that option 2 would add strong typing for Vindex params, but I think the main challenge is that out-of-tree Vindex plugins won't be able to take advantage of that.
I recommend option 1 because:
--vschema-strict
.Decision
I like the RAPID model for decision making.
Recommend: @maxenglander
Agree: @deepthi @systay
Perform: @maxenglander
Input: community
Decide: @harshit-gangal: "I think Option 1 is good as it does not change user behaviour and gives the option to log warnings to indicate the issue with the vindex setup."
Tasks
vindexes.ParamValidating
interface, via vindexes: return unknown params #12951 .vtctl
ApplyVSchema
CLI command, via vtctl,vindexes: logs warnings and export stat for unknown vindex params #13322.ApplyVSchemaResponse
gRPC response.The text was updated successfully, but these errors were encountered: