vitessio/vitess · error

table %s not found in vschema for keyspace %s

Error message

table %s not found in vschema for keyspace %s

What it means

buildMaterializer validates that every TableSettings.TargetTable exists in the target keyspace's VSchema when the target keyspace is sharded. A missing entry means the move/redistribute stream would target a table the vschema does not know about.

Source

Thrown at go/vt/wrangler/materializer.go:1065

		return err
	}
	return mz.startStreams(ctx)
}

func (wr *Wrangler) buildMaterializer(ctx context.Context, ms *vtctldatapb.MaterializeSettings) (*materializer, error) {
	vschema, err := wr.ts.GetVSchema(ctx, ms.TargetKeyspace)
	if err != nil {
		return nil, err
	}
	targetVSchema, err := vindexes.BuildKeyspaceSchema(vschema.Keyspace, ms.TargetKeyspace, wr.env.Parser())
	if err != nil {
		return nil, err
	}

	if targetVSchema.Keyspace.Sharded {
		for _, ts := range ms.TableSettings {
			if targetVSchema.Tables[ts.TargetTable] == nil {
				return nil, fmt.Errorf("table %s not found in vschema for keyspace %s", ts.TargetTable, ms.TargetKeyspace)
			}
		}
	}
	isPartial := false
	sourceShards, err := wr.sourceTs.GetServingShards(ctx, ms.SourceKeyspace)
	if err != nil {
		return nil, err
	}
	if len(ms.SourceShards) > 0 {
		isPartial = true
		var sourceShards2 []*topo.ShardInfo
		for _, shard := range sourceShards {
			if slices.Contains(ms.SourceShards, shard.ShardName()) {
				sourceShards2 = append(sourceShards2, shard)
			}
		}
		sourceShards = sourceShards2
	}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Run vtctldclient GetVSchema <targetKeyspace> and confirm the table is listed under tables.
  2. Add the table to the target keyspace vschema via ApplyVSchema, then retry the workflow.
  3. Fix typos in the table name supplied to the workflow command.

Example fix

// before: target vschema lacks the table
vtctldclient MoveTables --source commerce --target customer --tables corder
// after: add table to customer vschema first, then MoveTables
Defensive patterns

Strategy: validation

Validate before calling

targetVS, _ := wr.ts.GetVSchema(ctx, targetKeyspace)
if targetVS.Keyspace.Sharded {
  for _, ts := range tableSettings {
    if _, ok := targetVS.Tables[ts.TargetTable]; !ok {
      return fmt.Errorf("table %s missing in %s vschema", ts.TargetTable, targetKeyspace)
    }
  }
}

Prevention

When it happens

Trigger: prepareMaterializerStreams building a Materializer (Reshard/MoveTables-style flows) where ms.TableSettings references a table absent from targetVSchema.Tables.

Common situations: MoveTables/Reshard invoked for a table not present in the target keyspace vschema; typo in table name; vschema on the target keyspace not yet updated after adding a table.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/d559142acece31c3. Report an issue: GitHub.