vitessio/vitess · error

cannot execute remote command: %v

Error message

cannot execute remote command: %v

What it means

After dialing, RunCommandAndWait calls client.ExecuteVtctlCommand to start the remote command stream; any error from that RPC setup is wrapped as 'cannot execute remote command: <cause>'. This means the connection exists (or at least New succeeded) but the command could not be started on the server, commonly a transport-level gRPC failure or authentication/context error.

Source

Thrown at go/vt/vtctl/vtctlclient/wrapper.go:53

	if recv == nil {
		return errors.New("no function closure for Event stream specified")
	}
	// create the client
	client, err := New(ctx, server)
	if err != nil {
		return fmt.Errorf("cannot dial to server %v: %v", server, err)
	}
	defer client.Close()

	// run the command ( get the timeout from the context )
	timeout := defaultTimeout
	deadline, ok := ctx.Deadline()
	if ok {
		timeout = time.Until(deadline)
	}
	stream, err := client.ExecuteVtctlCommand(ctx, args, timeout)
	if err != nil {
		return fmt.Errorf("cannot execute remote command: %v", err)
	}

	// stream the result
	for {
		e, err := stream.Recv()
		switch err {
		case nil:
			recv(e)
		case io.EOF:
			return nil
		default:
			return fmt.Errorf("remote error: %v", err)
		}
	}
}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Read the wrapped cause: if it's a deadline error, increase the context timeout for long-running vtctl commands
  2. Check vtctld logs at the time of the call for server-side rejection reasons
  3. Verify client/server Vitess versions are compatible (no RPC skew)
  4. Retry the command once the server is confirmed stable; treat persistent failures as connectivity/TLS problems

Example fix

// before
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
// after
ctx, cancel := context.WithTimeout(ctx, 60*time.Second) // long commands need more
Defensive patterns

Strategy: retry

Validate before calling

if deadline, ok := ctx.Deadline(); ok && time.Until(deadline) < 30*time.Second {
  ctx, _ = context.WithTimeout(context.WithoutCancel(ctx), 60*time.Second)
}

Try / catch

err := vtctlclient.RunCommandAndWait(ctx, server, args, recv, true)
if err != nil && strings.Contains(err.Error(), "cannot execute remote command") {
  log.Warn("remote exec failed", slog.Any("error", err))
  // check server logs; retry only if cause is transient (Unavailable)
}

Prevention

When it happens

Trigger: Calling RunCommandAndWait where client.ExecuteVtctlCommand(ctx, args, timeout) returns an error: stream creation rejected, context deadline exceeded during setup, server-side rejection of the request, or connection dropped between dial and call.

Common situations: Timeout too short for the RPC handshake; vtctld restarting mid-command; TLS/auth mismatch after the dial succeeded; request rejected by server version skew.

Related errors


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