diff --git a/go/vt/topo/shard.go b/go/vt/topo/shard.go index 30fd5db1cda..7d4757742b8 100644 --- a/go/vt/topo/shard.go +++ b/go/vt/topo/shard.go @@ -326,28 +326,33 @@ func (ts *Server) CreateShard(ctx context.Context, keyspace, shard string) (err // GetOrCreateShard will return the shard object, or create one if it doesn't // already exist. Note the shard creation is protected by a keyspace Lock. func (ts *Server) GetOrCreateShard(ctx context.Context, keyspace, shard string) (si *ShardInfo, err error) { + log.Info("GetShard %s/%s", keyspace, shard) si, err = ts.GetShard(ctx, keyspace, shard) if !IsErrType(err, NoNode) { return } // create the keyspace, maybe it already exists + log.Info("CreateKeyspace %s/%s", keyspace, shard) if err = ts.CreateKeyspace(ctx, keyspace, &topodatapb.Keyspace{}); err != nil && !IsErrType(err, NodeExists) { return nil, vterrors.Wrapf(err, "CreateKeyspace(%v) failed", keyspace) } // make sure a valid vschema has been loaded + log.Info("EnsureVSchema %s/%s", keyspace, shard) if err = ts.EnsureVSchema(ctx, keyspace); err != nil { return nil, vterrors.Wrapf(err, "EnsureVSchema(%v) failed", keyspace) } // now try to create with the lock, may already exist + log.Info("CreateShard %s/%s", keyspace, shard) if err = ts.CreateShard(ctx, keyspace, shard); err != nil && !IsErrType(err, NodeExists) { return nil, vterrors.Wrapf(err, "CreateShard(%v/%v) failed", keyspace, shard) } // try to read the shard again, maybe someone created it // in between the original GetShard and the LockKeyspace + log.Info("GetShard %s/%s", keyspace, shard) return ts.GetShard(ctx, keyspace, shard) } diff --git a/go/vt/topo/vschema.go b/go/vt/topo/vschema.go index 2ea8d507716..00e5b2ea42b 100644 --- a/go/vt/topo/vschema.go +++ b/go/vt/topo/vschema.go @@ -43,11 +43,15 @@ func (ts *Server) SaveVSchema(ctx context.Context, keyspace string, vschema *vsc } _, err = ts.globalCell.Update(ctx, nodePath, data, nil) + if err != nil { + log.Info("successfully updated vschema for keyspace %s: %v", keyspace, data) + } return err } // DeleteVSchema delete the keyspace if it exists func (ts *Server) DeleteVSchema(ctx context.Context, keyspace string) error { + log.Info("deleting vschema for keyspace %s", keyspace) nodePath := path.Join(KeyspacesPath, keyspace, VSchemaFile) return ts.globalCell.Delete(ctx, nodePath, nil) } @@ -70,6 +74,9 @@ func (ts *Server) GetVSchema(ctx context.Context, keyspace string) (*vschemapb.K // EnsureVSchema makes sure that a vschema is present for this keyspace or creates a blank one if it is missing func (ts *Server) EnsureVSchema(ctx context.Context, keyspace string) error { vschema, err := ts.GetVSchema(ctx, keyspace) + if err != nil && !IsErrType(err, NoNode) { + log.Info("error in getting vschema for keyspace %s: %v", keyspace, err) + } if vschema == nil || IsErrType(err, NoNode) { err = ts.SaveVSchema(ctx, keyspace, &vschemapb.Keyspace{ Sharded: false,