vitessio/vitess · error

no shards in keyspace %v

Error message

no shards in keyspace %v

What it means

ValidatePermissionsKeyspace fetches the shard list for the keyspace and fails immediately if the keyspace has no shards at all, since there is nothing to validate. It is a guard against operating on an empty or nonexistent keyspace.

Source

Thrown at go/vt/wrangler/permissions.go:111

	wg.Wait()
	if er.HasErrors() {
		return fmt.Errorf("permissions diffs: %v", er.Error().Error())
	}
	return nil
}

// ValidatePermissionsKeyspace validates all the permissions are the same
// in a keyspace
func (wr *Wrangler) ValidatePermissionsKeyspace(ctx context.Context, keyspace string) error {
	// find all the shards
	shards, err := wr.ts.GetShardNames(ctx, keyspace)
	if err != nil {
		return err
	}

	// corner cases
	if len(shards) == 0 {
		return fmt.Errorf("no shards in keyspace %v", keyspace)
	}
	sort.Strings(shards)
	if len(shards) == 1 {
		return wr.ValidatePermissionsShard(ctx, keyspace, shards[0])
	}

	// find the reference permissions using the first shard's primary
	si, err := wr.ts.GetShard(ctx, keyspace, shards[0])
	if err != nil {
		return err
	}
	if !si.HasPrimary() {
		return fmt.Errorf("no primary in shard %v/%v", keyspace, shards[0])
	}
	referenceAlias := si.PrimaryAlias
	log.Info(fmt.Sprintf("Gathering permissions for reference primary %v", topoproto.TabletAliasString(referenceAlias)))
	referencePermissions, err := wr.GetPermissions(ctx, si.PrimaryAlias)
	if err != nil {

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Check the exact keyspace name with `vtctlclient GetKeyspaces` or `vtctlclient GetKeyspace <keyspace>`.
  2. List shards with `vtctlclient ListShards <keyspace>`; if empty, verify you meant a different keyspace.
  3. If the keyspace is genuinely empty and leftover, remove it (`vtctlclient DeleteKeyspace`) or create/populate shards before validating.
  4. If tablets exist but shards are missing in the topo, repair topology registration.

Example fix

// before
wr.ValidatePermissionsKeyspace(ctx, "commercee") // typo
// after
wr.ValidatePermissionsKeyspace(ctx, "commerce")
Defensive patterns

Strategy: validation

Validate before calling

shards, err := ts.GetShardNames(ctx, keyspace)
if err != nil { return err }
if len(shards) == 0 {
    return vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "keyspace %s has no shards; check keyspace name", keyspace)
}

Type guard

func keyspaceHasShards(shards []string) bool { return len(shards) > 0 }

Prevention

When it happens

Trigger: Calling `vtctlclient ValidatePermissionsKeyspace <keyspace>` where topo list of shards returns zero entries — either the keyspace name is mistyped or the keyspace was created but never sharded/assigned tablets.

Common situations: Typo in the keyspace name on the command line; keyspace created in the topo but shards not yet created (fresh setup, aborted init); keyspace was emptied after a full reshard/migration left it pending teardown.

Related errors


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