Skip to content
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

Add GenerateShardRanges to vtctl commands #6752

Merged
merged 5 commits into from
Sep 23, 2020

Conversation

ajm188
Copy link
Contributor

@ajm188 ajm188 commented Sep 20, 2020

Resolves #6751

Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
Copy link
Member

@rafael rafael left a comment

Choose a reason for hiding this comment

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

From my perspective this is a great idea to have a first class citizen. I've seen this come up multiple times in Slack where people it's not super sure about how to generate the shard ranges for a shard.

After thinking a bit more about this, we could also add this script to the contrib one. Personally, I think it makes more sense here.

@deepthi what do you think about this?

@@ -378,6 +378,9 @@ var commands = []commandGroup{
{"ListTablets", commandListTablets,
"<tablet alias> ...",
"Lists specified tablets in an awk-friendly way."},
{"ListShardRanges", commandListShardRanges,
Copy link
Member

Choose a reason for hiding this comment

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

nit - Maybe "GenerateShardRanges" ? I think List reads as something that already exists.

@deepthi
Copy link
Member

deepthi commented Sep 21, 2020

From my perspective this is a great idea to have a first class citizen. I've seen this come up multiple times in Slack where people it's not super sure about how to generate the shard ranges for a shard.

After thinking a bit more about this, we could also add this script to the contrib one. Personally, I think it makes more sense here.

@deepthi what do you think about this?

I think it's a great idea :) +1 on keeping it in the main repo and not in contrib.

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := listShardRanges(tt.args.shards)
if (err != nil) != tt.wantErr {
Copy link
Member

Choose a reason for hiding this comment

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

May I suggest replacing the more verbose comparisons with assert and require?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely!

Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
@ajm188 ajm188 changed the title Add ListShardRanges to vtctl commands Add GenerateShardRanges to vtctl commands Sep 21, 2020
func TestShardCalculatorForShardsGreaterThan512(t *testing.T) {
got, err := generateShardRanges(512)
if err != nil {
t.Errorf("listShardRanges() error = %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

missed a few

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🙈 oops! fixed

Signed-off-by: Andrew Mason <amason@slack-corp.com>
Copy link
Member

@deepthi deepthi left a comment

Choose a reason for hiding this comment

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

LGTM

start := 0
end := 0

// If shards does not divide evenly into maxShards, then there is some lossiness,
Copy link
Member

Choose a reason for hiding this comment

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

Nice implementation and documentation 👍

@deepthi deepthi merged commit 27fd491 into vitessio:master Sep 23, 2020
@askdba askdba added this to the v8.0 milestone Oct 6, 2020
@ajm188 ajm188 deleted the am_list_shard_ranges branch January 14, 2021 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose a shard range calculator as a vtctl command
4 participants