Skip to content

Commit

Permalink
Fixups after merge
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord committed Jan 5, 2025
1 parent 1333150 commit d3ebbe7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
8 changes: 8 additions & 0 deletions go/vt/topo/vschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ type KeyspaceVSchemaInfo struct {
version Version
}

func (k *KeyspaceVSchemaInfo) CloneVT() *KeyspaceVSchemaInfo {
return &KeyspaceVSchemaInfo{
Name: k.Name,
Keyspace: k.Keyspace.CloneVT(),
version: Version(k.version),
}
}

// SaveVSchema saves a Vschema. A valid Vschema should be passed in. It does not verify its correctness.
// If the VSchema is empty, just remove it.
func (ts *Server) SaveVSchema(ctx context.Context, ksvs *KeyspaceVSchemaInfo) error {
Expand Down
8 changes: 4 additions & 4 deletions go/vt/vtctl/workflow/lookup_vindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func newLookupVindex(ws *Server) *lookupVindex {

// prepareCreate performs the preparatory steps for creating a Lookup Vindex.
func (lv *lookupVindex) prepareCreate(ctx context.Context, workflow, keyspace string, specs *vschemapb.Keyspace, continueAfterCopyWithOwner bool) (
ms *vtctldatapb.MaterializeSettings, sourceVSchema, targetVSchema *vschemapb.Keyspace, cancelFunc func() error, err error) {
ms *vtctldatapb.MaterializeSettings, sourceVSchema, targetVSchema *topo.KeyspaceVSchemaInfo, cancelFunc func() error, err error) {
var (
// sourceVSchemaTable is the table info present in the vschema.
sourceVSchemaTable *vschemapb.Table
Expand Down Expand Up @@ -145,7 +145,7 @@ func (lv *lookupVindex) prepareCreate(ctx context.Context, workflow, keyspace st

// Save a copy of the original vschema if we modify it and need to provide
// a cancelFunc.
ogTargetVSchema := targetVSchema.CloneVT()
origTargetVSchema := targetVSchema.CloneVT()
targetChanged := false

// Update targetVSchema.
Expand Down Expand Up @@ -213,7 +213,7 @@ func (lv *lookupVindex) prepareCreate(ctx context.Context, workflow, keyspace st
if targetChanged {
cancelFunc = func() error {
// Restore the original target vschema.
return lv.ts.SaveVSchema(ctx, vInfo.targetKeyspace, ogTargetVSchema)
return lv.ts.SaveVSchema(ctx, origTargetVSchema)
}
}

Expand Down Expand Up @@ -324,7 +324,7 @@ func (lv *lookupVindex) validateAndGetVindex(specs *vschemapb.Keyspace) (*vschem
}, nil
}

func (lv *lookupVindex) getTargetAndSourceVSchema(ctx context.Context, sourceKeyspace string, targetKeyspace string) (sourceVSchema *vschemapb.Keyspace, targetVSchema *vschemapb.Keyspace, err error) {
func (lv *lookupVindex) getTargetAndSourceVSchema(ctx context.Context, sourceKeyspace, targetKeyspace string) (sourceVSchema, targetVSchema *topo.KeyspaceVSchemaInfo, err error) {
sourceVSchema, err = lv.ts.GetVSchema(ctx, sourceKeyspace)
if err != nil {
return nil, nil, err
Expand Down
10 changes: 5 additions & 5 deletions go/vt/wrangler/materializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ func (wr *Wrangler) MoveTables(ctx context.Context, workflow, sourceKeyspace, ta
log.Infof("Successfully opened external topo: %+v", externalTopo)
}

var vschema *topo.KeyspaceVSchemaInfo
origVSchema := &topo.KeyspaceVSchemaInfo{ // If we need to rollback a failed create
Name: targetKeyspace,
}
var (
vschema *topo.KeyspaceVSchemaInfo
origVSchema *topo.KeyspaceVSchemaInfo // If we need to rollback a failed create
)
vschema, err = wr.ts.GetVSchema(ctx, targetKeyspace)
if err != nil {
return err
Expand Down Expand Up @@ -216,7 +216,7 @@ func (wr *Wrangler) MoveTables(ctx context.Context, workflow, sourceKeyspace, ta
if !vschema.Sharded {
// Save the original in case we need to restore it for a late failure
// in the defer().
origVSchema.Keyspace = vschema.CloneVT()
origVSchema = vschema.CloneVT()
if err := wr.addTablesToVSchema(ctx, sourceKeyspace, vschema.Keyspace, tables, externalTopo == nil); err != nil {
return err
}
Expand Down

0 comments on commit d3ebbe7

Please sign in to comment.