-
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
Support KeyRange in --clusters_to_watch
flag
#17604
base: main
Are you sure you want to change the base?
Conversation
…exact shard values Signed-off-by: Manan Gupta <[email protected]>
Signed-off-by: Manan Gupta <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Signed-off-by: Manan Gupta <[email protected]>
// Refresh shards to watch. | ||
eg.Go(func() error { | ||
updateShardsToWatch() | ||
return nil | ||
}) | ||
|
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.
We don't need this anymore, because we don't store the explicit shard names for the keyspaces that we want to watch in the entirety. Instead we just store a complete key range and that doesn't change during the course of running of a VTOrc instance.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17604 +/- ##
==========================================
- Coverage 67.68% 67.63% -0.06%
==========================================
Files 1586 1586
Lines 255170 255625 +455
==========================================
+ Hits 172722 172888 +166
- Misses 82448 82737 +289 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Manan Gupta <[email protected]>
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.
LGTM, thanks @GuptaManan100 🚀
changelog/22.0/22.0.0/summary.md
Outdated
@@ -133,6 +134,11 @@ This is the last time this will be needed in the `8.0.x` series, as starting wit | |||
|
|||
The base system now uses Debian Bookworm instead of Debian Bullseye for the `vitess/lite` images. This change was brought by [Pull Request #17552]. | |||
|
|||
### <a id="key-range-vtorc"/>KeyRanges in `--clusters_to_watch` in VTOrc</a> | |||
VTOrc now supports specifying KeyRanges in the `--clusters_to_watch` flag. This is useful in scenarios where you don't need to restart a VTOrc instance if you run a reshard. | |||
For example, if a VTOrc is configured to watch `ks/-80`, then it would watch all the shards that fall under the KeyRange `-80`. If a reshard is run and, `-80` is split into new shards `-40`, and `40-80`, the VTOrc instance will automatically start watching the new shard without needing a restart. |
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.
@GuptaManan100 I think this explains the "new" behaviour very well, but I feel like a user of the old way won't fully understand the risks
For example, a user with --clusters_to_watch foo/-80
in the previous logic will watch 1 (or 0) shards only. After this change, with the same flag value they would watch any shard from -
to 80
, which could be surprising. So I guess I'm saying explaining the difference between the old logic and this PR might make this risk more clear
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.
What should I add to make it more clear? Should I add a line something like -
In the previous logic, watching a shard -80 would watch 1 (or 0) shard only. In the new system, since we interpret -80 as a key range, it can lead to a watch on multiple shards as described in the example.
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.
@GuptaManan100 that extra detail is great 👍
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.
LGTM! I just have the one noted concern. Let me know if I'm missing or misunderstanding something. Either way, I'll come back to this quickly and we can get it merged. ❤️
ks = strings.TrimSuffix(ks, "/") | ||
shards, err := ts.GetShardNames(ctx, ks) | ||
// Parse the shard name into key range value. | ||
_, keyRange, err := topo.ValidateShardName(s) |
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.
Your comments seemed to indicate that we don't support arbitrary shard names but only key ranges. This function supports both arbitrary names and key ranges. I think what you might want instead is key.IsValidKeyRange
and key.ParseShardingSpec
if keyRange == nil { | ||
keyRange = key.NewCompleteKeyRange() |
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 don't think this is correct, as the shard name can be "2" or "wassup" — in which case topo.ValidateShardName
will return nil for the KeyRange — and only cover a subset. This is related to my comment above.
Signed-off-by: Manan Gupta <[email protected]>
@mattlord I talked to @deepthi and she said that we only support In this light, the way the function is implemented (and corresponding tests verify this), is that if a users gives us something like Do you think it's worth adding the logic to continue to support arbitrary shard names? I can do that too, by basically creating another map from keyspace to shard names (like we had before), in addition to what we have, and store the shards that aren't range based in them, and continue to run equality checks for them. I personally, don't think we should add support for constructs that we've deprecated (I've added a catch-all to still watch all the shards), but I don't have strong opinions. |
That is exactly what the
But your usage of
I'm not suggesting we support arbitrary shard names, I'm suggesting that we do not allow it. 🙂 I'm not suggesting that we support shard names, I'm saying that currently we do support them because the input validator that you're using —
Yes, I know. I'm suggesting that the code should match your intentions here and do input validation and alert the user to this problematic usage (they can always just specify the keyspace name by itself).
IMO Does this make sense? I don't feel too strongly about it, so I'm OK with you making the final call. |
@GuptaManan100 why I think this discussion is worth having and why IMO we should do proper input validation is this... let's say that I have two shards: |
Description
This PR addresses the feature request #17537.
Now
clusters_to_watch
flag accepts key ranges. The format for input is still the same, and therefore backward compatible.Internally Vitess now treats the input as key ranges instead of explicit shard names.
This allows the users to not restart VTOrc in case of a reshard. For example, if a VTOrc is configured to watch
ks/-80
, then it would watch all the shards that fall under the KeyRange-80
. If a reshard is run and,-80
is split into new shards-40
, and40-80
, the VTOrc instance will automatically start watching the new shard without needing a restart.As part of this change, I have restructured the
shardsToWatch
map to store key ranges instead of strings. I've also made it so that we don't need to update the shards information by insteading storing in the map that we are watching all the shards using a complete key range.Related Issue(s)
--clusters_to_watch
#17537Checklist
Deployment Notes