8000 `slack-19.0`: pre-backport v23 vtorc PR vitessio/vitess#17985 by timvaillancourt · Pull Request #635 · slackhq/vitess · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

slack-19.0: pre-backport v23 vtorc PR vitessio/vitess#17985 #635

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

Open
wants to merge 6 commits into
base: slack-19.0
Choose a base branch
from
Open
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
5 changes: 2 additions & 3 deletions go/cmd/vtctldclient/command/keyspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ import (

"github.com/spf13/cobra"

"vitess.io/vitess/go/mysql/sqlerror"
"vitess.io/vitess/go/protoutil"

"vitess.io/vitess/go/cmd/vtctldclient/cli"
"vitess.io/vitess/go/constants/sidecar"
"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/mysql/sqlerror"
"vitess.io/vitess/go/protoutil"
topodatapb "vitess.io/vitess/go/vt/proto/topodata"
vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata"
"vitess.io/vitess/go/vt/proto/vttime"
Expand Down
49 changes: 48 additions & 1 deletion go/cmd/vtctldclient/command/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"github.com/spf13/cobra"

"vitess.io/vitess/go/cmd/vtctldclient/cli"

vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata"
"vitess.io/vitess/go/vt/topo/topoproto"
)

var (
Expand All @@ -35,6 +35,16 @@ var (
Args: cobra.ExactArgs(1),
RunE: commandGetTopologyPath,
}

// SetVtorcEmergencyReparent enables/disables the use of EmergencyReparentShard in VTOrc recoveries for a given keyspace or keyspace/shard.
SetVtorcEmergencyReparent = &cobra.Command{
Use: "SetVtorcEmergencyReparent [--enable|-e] [--disable|-d] <keyspace> <shard>",
Short: "Enable/disables the use of EmergencyReparentShard in VTOrc recoveries for a given keyspace or keyspace/shard.",
DisableFlagsInUseLine: true,
Aliases: []string{"setvtorcemergencyreparent"},
Args: cobra.RangeArgs(1, 2),
RunE: commandSetVtorcEmergencyReparent,
}
)

func commandGetTopologyPath(cmd *cobra.Command, args []string) error {
Expand All @@ -59,6 +69,43 @@ func commandGetTopologyPath(cmd *cobra.Command, args []string) error {
return nil
}

var setVtorcEmergencyReparentOptions = struct {
Disable bool
Enable bool
}{}

func commandSetVtorcEmergencyReparent(cmd *cobra.Command, args []string) error {
cli.FinishedParsing(cmd)

ks := cmd.Flags().Arg(0)
shard := cmd.Flags().Arg(1)
keyspaceShard := topoproto.KeyspaceShardString(ks, shard)
if !setVtorcEmergencyReparentOptions.Disable && !setVtorcEmergencyReparentOptions.Enable {
return fmt.Errorf("SetVtorcEmergencyReparent(%v) error: must set --enable or --disable flag", keyspaceShard)
}
if setVtorcEmergencyReparentOptions.Disable && setVtorcEmergencyReparentOptions.Enable {
return fmt.Errorf("SetVtorcEmergencyReparent(%v) error: --enable and --disable flags are mutually exclusive", keyspaceShard)
}

_, err := client.SetVtorcEmergencyReparent(commandCtx, &vtctldatapb.SetVtorcEmergencyReparentRequest{
Keyspace: ks,
Shard: shard,
Disable: setVtorcEmergencyReparentOptions.Disable,
})

if err != nil {
return fmt.Errorf("SetVtorcEmergencyReparent(%v) error: %w; please check the topo", keyspaceShard, err)
}

fmt.Printf("Successfully updated keyspace/shard %v.\n", keyspaceShard)

return nil
}

func init() {
Root.AddCommand(GetTopologyPath)

Root.AddCommand(SetVtorcEmergencyReparent)
SetVtorcEmergencyReparent.Flags().BoolVarP(&setVtorcEmergencyReparentOptions.Disable, "disable", "d", false, "Disable the use of EmergencyReparentShard in recoveries.")
SetVtorcEmergencyReparent.Flags().BoolVarP(&setVtorcEmergencyReparentOptions.Enable, "enable", "e", false, "Enable the use of EmergencyReparentShard in recoveries.")
}
1 change: 1 addition & 0 deletions go/flags/endtoend/vtctldclient.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Available Commands:
SetKeyspaceDurabilityPolicy Sets the durability-policy used by the specified keyspace.
SetShardIsPrimaryServing Add or remove a shard from serving. This is meant as an emergency function. It does not rebuild any serving graphs; i.e. it does not run `RebuildKeyspaceGraph`.
SetShardTabletControl Sets the TabletControl record for a shard and tablet type. Only use this for an emergency fix or after a finished MoveTables.
SetVtorcEmergencyReparent Enable/disables the use of EmergencyReparentShard in VTOrc recoveries for a given keyspace or keyspace/shard.
SetWritable Sets the specified tablet as writable or read-only.
ShardReplicationFix Walks through a ShardReplication object and fixes the first error encountered.
ShardReplicationPositions
Expand Down
1 change: 1 addition & 0 deletions go/test/endtoend/vtorc/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func TestAPIEndpoints(t *testing.T) {
"TableName": "vitess_keyspace",
"Rows": [
{
"disable_emergency_reparent": "0",
"durability_policy": "none",
"keyspace": "ks",
"keyspace_type": "0"
Expand Down
2 changes: 1 addition & 1 deletion go/vt/discovery/tablet_picker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ func newPickerTestEnv(t *testing.T, ctx context.Context, cells []string, extraCe
require.NoError(t, err)
err = te.topoServ.CreateKeyspace(ctx, te.keyspace, &topodatapb.Keyspace{})
require.NoError(t, err)
err = te.topoServ.CreateShard(ctx, te.keyspace, te.shard)
err = te.topoServ.CreateShard(ctx, te.keyspace, te.shard, nil)
require.NoError(t, err)
return te
}
Expand Down
2 changes: 1 addition & 1 deletion go/vt/mysqlctl/backup_blackbox_race_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TestExecuteBackupWithFailureOnLastFile(t *testing.T) {
defer ts.Close()

require.NoError(t, ts.CreateKeyspace(ctx, keyspace, &topodata.Keyspace{}))
require.NoError(t, ts.CreateShard(ctx, keyspace, shard))
require.NoError(t, ts.CreateShard(ctx, keyspace, shard, nil))

tablet := topo.NewTablet(100, "cell1", "mykeyspace-00-80-0100")
tablet.Keyspace = keyspace
Expand Down
8 changes: 4 additions & 4 deletions go/vt/mysqlctl/backup_blackbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestExecuteBackup(t *testing.T) {
defer ts.Close()

require.NoError(t, ts.CreateKeyspace(ctx, keyspace, &topodata.Keyspace{}))
require.NoError(t, ts.CreateShard(ctx, keyspace, shard))
require.NoError(t, ts.CreateShard(ctx, keyspace, shard, nil))

tablet := topo.NewTablet(100, "cell1", "mykeyspace-00-80-0100")
tablet.Keyspace = keyspace
Expand Down Expand Up @@ -258,7 +258,7 @@ func TestExecuteBackupWithSafeUpgrade(t *testing.T) {
defer ts.Close()

require.NoError(t, ts.CreateKeyspace(ctx, keyspace, &topodata.Keyspace{}))
require.NoError(t, ts.CreateShard(ctx, keyspace, shard))
require.NoError(t, ts.CreateShard(ctx, keyspace, shard, nil))

tablet := topo.NewTablet(100, "cell1", "mykeyspace-00-80-0100")
tablet.Keyspace = keyspace
Expand Down Expand Up @@ -351,7 +351,7 @@ func TestExecuteBackupWithCanceledContext(t *testing.T) {
defer ts.Close()

require.NoError(t, ts.CreateKeyspace(ctx, keyspace, &topodata.Keyspace{}))
require.NoError(t, ts.CreateShard(ctx, keyspace, shard))
require.NoError(t, ts.CreateShard(ctx, keyspace, shard, nil))

tablet := topo.NewTablet(100, "cell1", "mykeyspace-00-80-0100")
tablet.Keyspace = keyspace
Expand Down Expand Up @@ -440,7 +440,7 @@ func TestExecuteRestoreWithTimedOutContext(t *testing.T) {
defer ts.Close()

require.NoError(t, ts.CreateKeyspace(ctx, keyspace, &topodata.Keyspace{}))
require.NoError(t, ts.CreateShard(ctx, keyspace, shard))
require.NoError(t, ts.CreateShard(ctx, keyspace, shard, nil))

tablet := topo.NewTablet(100, "cell1", "mykeyspace-00-80-0100")
tablet.Keyspace = keyspace
Expand Down
Loading
Loading
0