Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions go/cmd/vtctldclient/command/shards.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ Use ctrl-C to interrupt the command and see partial results if needed.`,
Args: cobra.ExactArgs(2),
RunE: commandSourceShardDelete,
}

// ValidateVersionShard makes a ValidateVersionShard gRPC request to a vtctld.
ValidateVersionShard = &cobra.Command{
Use: "ValidateVersionShard <keyspace/shard>",
Short: "Validates that the version on the primary matches all of the replicas.",
DisableFlagsInUseLine: true,
Args: cobra.ExactArgs(1),
RunE: commandValidateVersionShard,
}
)

var createShardOptions = struct {
Expand Down Expand Up @@ -546,6 +555,31 @@ func commandSourceShardDelete(cmd *cobra.Command, args []string) error {
return nil
}

func commandValidateVersionShard(cmd *cobra.Command, args []string) error {
keyspace, shard, err := topoproto.ParseKeyspaceShard(cmd.Flags().Arg(0))
if err != nil {
return err
}

cli.FinishedParsing(cmd)

resp, err := client.ValidateVersionShard(commandCtx, &vtctldatapb.ValidateVersionShardRequest{
Keyspace: keyspace,
Shard: shard,
})
if err != nil {
return err
}

data, err := cli.MarshalJSON(resp)
if err != nil {
return err
}

fmt.Printf("%s\n", data)
return nil
}

func init() {
CreateShard.Flags().BoolVarP(&createShardOptions.Force, "force", "f", false, "Overwrite an existing shard record, if one exists.")
CreateShard.Flags().BoolVarP(&createShardOptions.IncludeParent, "include-parent", "p", false, "Creates the parent keyspace record if does not already exist.")
Expand Down Expand Up @@ -574,6 +608,7 @@ func init() {
Root.AddCommand(ShardReplicationFix)
Root.AddCommand(ShardReplicationPositions)
Root.AddCommand(ShardReplicationRemove)
Root.AddCommand(ValidateVersionShard)

SourceShardAdd.Flags().StringVar(&sourceShardAddOptions.KeyRangeStr, "key-range", "", "Key range to use for the SourceShard.")
SourceShardAdd.Flags().StringSliceVar(&sourceShardAddOptions.Tables, "tables", nil, "Comma-separated lists of tables to replicate (for MoveTables). Each table name is either an exact match, or a regular expression of the form \"/regexp/\".")
Expand Down
1 change: 1 addition & 0 deletions go/flags/endtoend/vtctldclient.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Available Commands:
ValidateSchemaKeyspace Validates that the schema on the primary tablet for shard 0 matches the schema on all other tablets in the keyspace.
ValidateShard Validates that all nodes reachable from the specified shard are consistent.
ValidateVersionKeyspace Validates that the version on the primary tablet of shard 0 matches all of the other tablets in the keyspace.
ValidateVersionShard Validates that the version on the primary matches all of the replicas.
completion Generate the autocompletion script for the specified shell
help Help about any command

Expand Down
Loading