From d3ebbe7bd495b0e2ca441f516464016274b34c8e Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Sun, 5 Jan 2025 13:01:35 -0500 Subject: [PATCH] Fixups after merge Signed-off-by: Matt Lord --- go/vt/topo/vschema.go | 8 ++++++++ go/vt/vtctl/workflow/lookup_vindex.go | 8 ++++---- go/vt/wrangler/materializer.go | 10 +++++----- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/go/vt/topo/vschema.go b/go/vt/topo/vschema.go index 6e685423dbf..e9e679ffeb9 100644 --- a/go/vt/topo/vschema.go +++ b/go/vt/topo/vschema.go @@ -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 { diff --git a/go/vt/vtctl/workflow/lookup_vindex.go b/go/vt/vtctl/workflow/lookup_vindex.go index cf9b4833c28..15204b57a37 100644 --- a/go/vt/vtctl/workflow/lookup_vindex.go +++ b/go/vt/vtctl/workflow/lookup_vindex.go @@ -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 @@ -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. @@ -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) } } @@ -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 diff --git a/go/vt/wrangler/materializer.go b/go/vt/wrangler/materializer.go index 96067cd64e4..27aaa6935be 100644 --- a/go/vt/wrangler/materializer.go +++ b/go/vt/wrangler/materializer.go @@ -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 @@ -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 }