vitessio/vitess · error

CreateTablet(%v): %w

Error message

CreateTablet(%v): %w

What it means

CopyTablets copies tablet objects from a source topo server to a destination topo server. This error wraps any failure encountered when creating a tablet in the destination topo, either via toTS.CreateTablet or via toTS.UpdateTabletFields, and prefixes it with the tablet alias so the failing tablet is identifiable.

Source

Thrown at go/vt/topo/helpers/copy.go:146

			for _, tabletAlias := range tabletAliases {
				// read the source tablet
				ti, err := fromTS.GetTablet(ctx, tabletAlias)
				if err != nil {
					return fmt.Errorf("GetTablet(%v): %w", tabletAlias, err)
				}

				// try to create the destination
				err = toTS.CreateTablet(ctx, ti.Tablet)
				if topo.IsErrType(err, topo.NodeExists) {
					// update the destination tablet
					log.Warn(fmt.Sprintf("tablet %v already exists, updating it", tabletAlias))
					_, err = toTS.UpdateTabletFields(ctx, tabletAlias, func(t *topodatapb.Tablet) error {
						proto.Merge(t, ti.Tablet)
						return nil
					})
				}
				if err != nil {
					return fmt.Errorf("CreateTablet(%v): %w", tabletAlias, err)
				}
			}
		}
	}

	return nil
}

// CopyShardReplications will create the ShardReplication objects in
// the destination topo.
func CopyShardReplications(ctx context.Context, fromTS, toTS *topo.Server) error {
	keyspaces, err := fromTS.GetKeyspaces(ctx)
	if err != nil {
		return fmt.Errorf("fromTS.GetKeyspaces: %w", err)
	}

	cells, err := fromTS.GetCellInfoNames(ctx)
	if err != nil {

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Check the wrapped inner error to find the actual cause (e.g. node already exists in destination topo)
  2. Ensure destination topo cells are initialized (CreateCellInfo) before CopyTablets
  3. Clean or diff destination tablets that already exist before re-running the copy
  4. Verify destination topo server connectivity and credentials

Example fix

// before
_, err = toTS.CreateTablet(ctx, ti.Tablet)
// after
err := toTS.CreateTablet(ctx, ti.Tablet)
if topo.IsErrType(err, topo.NodeExists) {
    _, err = toTS.UpdateTabletFields(ctx, tabletAlias, func(t *topodatapb.Tablet) error {
        proto.Merge(t, ti.Tablet)
        return nil
    })
}
Defensive patterns

Strategy: try-catch

Validate before calling

cells, err := toTS.GetCellInfoNames(ctx)
if err != nil || len(cells) == 0 {
    return fmt.Errorf("destination topo cells not ready: %w", err)
}

Type guard

func isNodeExists(err error) bool { return topo.IsErrType(err, topo.NodeExists) }

Try / catch

err := helpers.CopyTablets(ctx, fromTS, toTS)
if err != nil {
    var tabletErr error
    if errors.Unwrap(err) != nil { tabletErr = errors.Unwrap(err) }
    log.Errorf("copy failed: %v (cause: %v)", err, tabletErr)
}

Prevention

When it happens

Trigger: Calling topo/helpers.CopyTablets when the destination topo rejects a tablet insert/update: node already exists, destination cell not present in destination topo, or an underlying connection error from toTS.UpdateTabletFields.

Common situations: Copying a topology into a partially-initialized destination topo during vtctld copy operations or tests (copyTopos); destination already contains the tablet from a previous copy; network outage between the destination topo server and its backend.

Related errors


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