-
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.62% -0.07%
==========================================
Files 1586 1586
Lines 255170 255627 +457
==========================================
+ Hits 172722 172877 +155
- Misses 82448 82750 +302 ☔ 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 🚀
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. ❤️
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: |
Yes, I see what you mean. You're right, I'll make the change ❤️ |
Signed-off-by: Manan Gupta <[email protected]>
Signed-off-by: Manan Gupta <[email protected]>
I've made both the changes @mattlord! You can take a look again! Thank you! |
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.
Thanks, @GuptaManan100 ! I like it 🙂
Signed-off-by: Manan Gupta <[email protected]>
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.
Nice improvement! A few small things to fix, mostly wording and naming.
@@ -135,6 +136,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. |
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.
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. | |
VTOrc now supports specifying keyranges in the `--clusters_to_watch` flag. This means that there is no need to restart a VTOrc instance with a different flag value when you reshard a keyspace. |
@@ -135,6 +136,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. 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.
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. 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. | |
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 performed and `-80` is split into new shards `-40` and `40-80`, the VTOrc instance will automatically start watching the new shards without needing a restart. In the previous logic, specifying `ks/-80` for the flag would mean that VTOrc would watch only 1 (or no) shard. In the new system, since we interpret `-80` as a key range, it can watch multiple shards as described in the example. |
### <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. 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. | ||
The users can still continue to specify exact key ranges too, and the new feature is backward compatible. |
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.
The users can still continue to specify exact key ranges too, and the new feature is backward compatible. | |
Users can continue to specify exact keyranges. The new feature is backward compatible. |
@@ -24,7 +24,7 @@ Flags: | |||
--bind-address string Bind address for the server. If empty, the server will listen on all available unicast and anycast IP addresses of the local system. | |||
--catch-sigpipe catch and ignore SIGPIPE on stdout and stderr if specified | |||
--change-tablets-with-errant-gtid-to-drained Whether VTOrc should be changing the type of tablets with errant GTIDs to DRAINED | |||
--clusters_to_watch strings Comma-separated list of keyspaces or keyspace/shards that this instance will monitor and repair. Defaults to all clusters in the topology. Example: "ks1,ks2/-80" | |||
--clusters_to_watch strings Comma-separated list of keyspaces or keyspace/key-ranges that this instance will monitor and repair. Defaults to all clusters in the topology. Example: "ks1,ks2/-80" |
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.
--clusters_to_watch strings Comma-separated list of keyspaces or keyspace/key-ranges that this instance will monitor and repair. Defaults to all clusters in the topology. Example: "ks1,ks2/-80" | |
--clusters_to_watch strings Comma-separated list of keyspaces or keyspace/shard ranges that this instance will monitor and repair. Defaults to all clusters in the topology. Example: "ks1,ks2/-80" |
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'm not certain about this change. it may be better to call it keyranges (without the -).
defer shardsToWatchMu.Unlock() | ||
shardsToWatch = newShardsToWatch | ||
// tabletPartOfWatch checks if the given tablet is part of the watch list. | ||
func tabletPartOfWatch(tablet *topodatapb.Tablet) bool { |
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.
func tabletPartOfWatch(tablet *topodatapb.Tablet) bool { | |
func shouldWatchTablet(tablet *topodatapb.Tablet) bool { |
@@ -102,71 +103,216 @@ var ( | |||
} | |||
) | |||
|
|||
func TestUpdateShardsToWatch(t *testing.T) { | |||
func TestTabletsPartOfWatch(t *testing.T) { |
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.
Rename test to match function.
testCases := []struct { | ||
in []string | ||
tablet *topodatapb.Tablet | ||
expectedPartOfWatch bool |
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.
expectedPartOfWatch bool | |
expectedShouldWatch bool |
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