Skip to content

Commit

Permalink
Moar minor nits/changes
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord committed Sep 11, 2023
1 parent 10ad9b9 commit 47547f9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 24 deletions.
8 changes: 5 additions & 3 deletions go/test/endtoend/vreplication/vreplication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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}
Expand Down
2 changes: 2 additions & 0 deletions go/vt/vtctl/grpcvtctldserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
29 changes: 16 additions & 13 deletions go/vt/vtctl/workflow/resharder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions go/vt/vtctl/workflow/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand Down

0 comments on commit 47547f9

Please sign in to comment.