diff --git a/go/test/endtoend/vreplication/vreplication_test.go b/go/test/endtoend/vreplication/vreplication_test.go index db7bcac9d87..d5bb3b87609 100644 --- a/go/test/endtoend/vreplication/vreplication_test.go +++ b/go/test/endtoend/vreplication/vreplication_test.go @@ -790,9 +790,10 @@ func shardCustomer(t *testing.T, testReverse bool, cells []*Cell, sourceCellOrAl matchInsertQuery1 := "insert into customer(cid, `name`) values (:vtg1 /* INT64 */, :vtg2 /* VARCHAR */)" require.True(t, validateThatQueryExecutesOnTablet(t, vtgateConn, productTab, "product", insertQuery1, matchInsertQuery1)) - // FIXME for some reason, these inserts fails on mac, need to investigate, some vreplication bug because of case insensitiveness of table names on mac? + // FIXME for some reason, these inserts fails on mac, need to investigate, some + // vreplication bug because of case insensitiveness of table names on mac? if runtime.GOOS == "linux" { - // confirm that the backticking of table names in the routing rules works + // Confirm that the backticking of table names in the routing rules works. tbls := []string{"Lead", "Lead-1"} for _, tbl := range tbls { output, err := osExec(t, "mysql", []string{"-u", "vtdba", "-P", fmt.Sprintf("%d", vc.ClusterConfig.vtgateMySQLPort), @@ -1407,7 +1408,8 @@ func moveTablesActionWithTabletTypes(t *testing.T, action, cell, workflow, sourc } } -// reshardAction is a helper function to run the reshard command, using the vtctldclient commands. +// reshardAction is a helper function to run the reshard command and +// action using vtctldclient. func reshardAction(t *testing.T, action, workflow, keyspaceName, sourceShards, targetShards, cell, tabletTypes string, extraFlags ...string) { var err error args := []string{"Reshard", "--workflow=" + workflow, "--target-keyspace=" + keyspaceName, action} diff --git a/go/vt/vtctl/grpcvtctldserver/server.go b/go/vt/vtctl/grpcvtctldserver/server.go index 15c58616382..67ab532a5ef 100644 --- a/go/vt/vtctl/grpcvtctldserver/server.go +++ b/go/vt/vtctl/grpcvtctldserver/server.go @@ -3012,6 +3012,8 @@ func (s *VtctldServer) ReshardCreate(ctx context.Context, req *vtctldatapb.Resha span.Annotate("keyspace", req.Keyspace) span.Annotate("workflow", req.Workflow) span.Annotate("cells", req.Cells) + span.Annotate("source_shards", req.SourceShards) + span.Annotate("target_shards", req.TargetShards) span.Annotate("tablet_types", req.TabletTypes) span.Annotate("on_ddl", req.OnDdl) diff --git a/go/vt/vtctl/workflow/resharder.go b/go/vt/vtctl/workflow/resharder.go index e1accaf5666..161b1c4567d 100644 --- a/go/vt/vtctl/workflow/resharder.go +++ b/go/vt/vtctl/workflow/resharder.go @@ -29,27 +29,30 @@ import ( "vitess.io/vitess/go/sqltypes" "vitess.io/vitess/go/vt/concurrency" "vitess.io/vitess/go/vt/key" - binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata" - vschemapb "vitess.io/vitess/go/vt/proto/vschema" "vitess.io/vitess/go/vt/schema" "vitess.io/vitess/go/vt/topo" "vitess.io/vitess/go/vt/topotools" "vitess.io/vitess/go/vt/vterrors" "vitess.io/vitess/go/vt/vtgate/vindexes" "vitess.io/vitess/go/vt/vttablet/tabletmanager/vreplication" + + binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata" + vschemapb "vitess.io/vitess/go/vt/proto/vschema" ) type resharder struct { - s *Server - keyspace string - workflow string - sourceShards []*topo.ShardInfo - sourcePrimaries map[string]*topo.TabletInfo - targetShards []*topo.ShardInfo - targetPrimaries map[string]*topo.TabletInfo - vschema *vschemapb.Keyspace - refStreams map[string]*refStream - cell string //single cell or cellsAlias or comma-separated list of cells/cellsAliases + s *Server + keyspace string + workflow string + sourceShards []*topo.ShardInfo + sourcePrimaries map[string]*topo.TabletInfo + targetShards []*topo.ShardInfo + targetPrimaries map[string]*topo.TabletInfo + vschema *vschemapb.Keyspace + refStreams map[string]*refStream + // This can be single cell name or cell alias but it can + // also be a comma-separated list of cells. + cell string tabletTypes string stopAfterCopy bool onDDL string @@ -300,7 +303,7 @@ func (rs *resharder) createStreams(ctx context.Context) error { for _, rstream := range rs.refStreams { ig.AddRow(rstream.workflow, rstream.bls, "", rstream.cell, rstream.tabletTypes, - //todo: fix based on original stream + // TODO: fix based on original stream. binlogdatapb.VReplicationWorkflowType_Reshard, binlogdatapb.VReplicationWorkflowSubType_None, rs.deferSecondaryKeys) diff --git a/go/vt/vtctl/workflow/server.go b/go/vt/vtctl/workflow/server.go index 73c45989467..38b57795d19 100644 --- a/go/vt/vtctl/workflow/server.go +++ b/go/vt/vtctl/workflow/server.go @@ -28,10 +28,6 @@ import ( "text/template" "time" - "vitess.io/vitess/go/vt/mysqlctl/tmutils" - "vitess.io/vitess/go/vt/vtctl/schematools" - "vitess.io/vitess/go/vt/vttablet/tabletmanager/vreplication" - "golang.org/x/sync/semaphore" "google.golang.org/protobuf/encoding/prototext" @@ -44,14 +40,17 @@ import ( "vitess.io/vitess/go/vt/key" "vitess.io/vitess/go/vt/log" "vitess.io/vitess/go/vt/logutil" + "vitess.io/vitess/go/vt/mysqlctl/tmutils" "vitess.io/vitess/go/vt/schema" "vitess.io/vitess/go/vt/sqlparser" "vitess.io/vitess/go/vt/topo" "vitess.io/vitess/go/vt/topo/topoproto" "vitess.io/vitess/go/vt/topotools" + "vitess.io/vitess/go/vt/vtctl/schematools" "vitess.io/vitess/go/vt/vtctl/workflow/vexec" "vitess.io/vitess/go/vt/vterrors" "vitess.io/vitess/go/vt/vtgate/vindexes" + "vitess.io/vitess/go/vt/vttablet/tabletmanager/vreplication" "vitess.io/vitess/go/vt/vttablet/tmclient" binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata" @@ -1252,24 +1251,25 @@ func (s *Server) ReshardCreate(ctx context.Context, req *vtctldatapb.ReshardCrea span.Annotate("keyspace", req.Keyspace) span.Annotate("workflow", req.Workflow) + span.Annotate("source_shards", req.SourceShards) + span.Annotate("target_shards", req.TargetShards) span.Annotate("cells", req.Cells) span.Annotate("tablet_types", req.TabletTypes) span.Annotate("on_ddl", req.OnDdl) keyspace := req.Keyspace cells := req.Cells - // TODO validate workflow does not exist + // TODO: validate workflow does not exist. if err := s.ts.ValidateSrvKeyspace(ctx, keyspace, strings.Join(cells, ",")); err != nil { err2 := vterrors.Wrapf(err, "SrvKeyspace for keyspace %s is corrupt for cell(s) %s", keyspace, cells) log.Errorf("%w", err2) return nil, err } - rs, err := s.buildResharder(ctx, keyspace, req.Workflow, req.SourceShards, req.TargetShards, strings.Join(cells, ","), "") //fixme + rs, err := s.buildResharder(ctx, keyspace, req.Workflow, req.SourceShards, req.TargetShards, strings.Join(cells, ","), "") if err != nil { return nil, vterrors.Wrap(err, "buildResharder") } - _ = rs rs.onDDL = req.OnDdl rs.stopAfterCopy = req.StopAfterCopy rs.deferSecondaryKeys = req.DeferSecondaryKeys @@ -1287,7 +1287,7 @@ func (s *Server) ReshardCreate(ctx context.Context, req *vtctldatapb.ReshardCrea return nil, vterrors.Wrap(err, "startStreams") } } else { - log.Warningf("Streams will not be started since -auto_start is set to false") + log.Warningf("Streams will not be started since --auto-start is set to false") } return nil, nil }