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

vtexplain2 #6705

Merged
merged 8 commits into from
Sep 13, 2020
Merged

vtexplain2 #6705

merged 8 commits into from
Sep 13, 2020

Conversation

ajm188
Copy link
Contributor

@ajm188 ajm188 commented Sep 11, 2020

This PR enables vtexplain to use non-evenly sharded keyspaces, by consuming a new piece of user input, namely a json blob in the form of { "ks1": $(vtctl FindAllShardsInKeyspace ks1), "ks2": $(vtctl FindAllShardsInKeyspace ks2) }.

A few notable changes were required for this to work:

  • Add two new flags ks-shard-map and ks-shard-map-file to get the new json blob, in the same style as the sql/sqlfile and vschema/vschema-file args. For this, I made getFileParam take an additional arg to dictate whether a failure to pass exactly one of the two arguments should result in an error. This makes it so that ks-shard-map/ks-shard-map-file are optional. Failure to pass exactly one of them will cause vtexplain to fall back to the old NumShards behavior.
  • ExplainTopo now tracks a nested map of topodatapb.ShardReference pointers, (so, keyspace -> shard_name -> shard_ref). ExplainTopo then uses this to construct a topodatapb.SrvKeyspace in GetSrvKeyspace() rather than doing it based on just NumShards + an assumption of evenly-sharded keyranges. This is the piece that gives us the flexibility to allow arbitrarily-sharded keyspaces.
  • buildTopology constructs a set of ShardReferences and TabletConns based on the keyspaceShardMap. If the user didn't provide a keyspaceShardMap, go back to the NumShards+even sharding behavior. The significant change here is that this function must update the ExplainTopo.KeyspaceShards map, or it will return incorrect data when GetSrvKeyspace() is called on it.

I've manually tested that both the new and old behaviors work on sharded keyspaces so far, but I wanted to get input at this point.

I'll note that this code can probably simplified if we decide we don't want to support the NumShards case, and instead require users to give a json map of keyspace -> shard name -> shard ref. But, I also understand if we need to keep supporting that, if even for a little while.

Signed-off-by: Andrew Mason <amason@slack-corp.com>
…hards to construct a topo

Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
@ajm188 ajm188 requested a review from sougou as a code owner September 11, 2020 19:36
Signed-off-by: Andrew Mason <amason@slack-corp.com>
Copy link
Contributor

@sougou sougou left a comment

Choose a reason for hiding this comment

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

Cool. Could you write some tests that demonstrate the new functionality? Also, we'll need to update the documentation https://vitess.io/docs/reference/programs/vtexplain/

Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
…s runs

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

ajm188 commented Sep 12, 2020

Tests added, and preliminary documentation change is here!

@sougou sougou merged commit 2095043 into vitessio:master Sep 13, 2020
ajm188 pushed a commit to tinyspeck/vitess that referenced this pull request Sep 14, 2020
@askdba askdba added this to the v8.0 milestone Oct 6, 2020
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.

3 participants