{"record":{"id":"853f6baab7375d32","repo":"vitessio/vitess","slug":"cannot-execute-remote-command-v","errorCode":null,"errorMessage":"cannot execute remote command: %v","messagePattern":"cannot execute remote command: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/vtctlclient/wrapper.go","lineNumber":53,"sourceCode":"\tif recv == nil {\n\t\treturn errors.New(\"no function closure for Event stream specified\")\n\t}\n\t// create the client\n\tclient, err := New(ctx, server)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot dial to server %v: %v\", server, err)\n\t}\n\tdefer client.Close()\n\n\t// run the command ( get the timeout from the context )\n\ttimeout := defaultTimeout\n\tdeadline, ok := ctx.Deadline()\n\tif ok {\n\t\ttimeout = time.Until(deadline)\n\t}\n\tstream, err := client.ExecuteVtctlCommand(ctx, args, timeout)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot execute remote command: %v\", err)\n\t}\n\n\t// stream the result\n\tfor {\n\t\te, err := stream.Recv()\n\t\tswitch err {\n\t\tcase nil:\n\t\t\trecv(e)\n\t\tcase io.EOF:\n\t\t\treturn nil\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"remote error: %v\", err)\n\t\t}\n\t}\n}\n","sourceCodeStart":35,"sourceCodeEnd":69,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/vtctlclient/wrapper.go#L35-L69","documentation":"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.","triggerScenarios":"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.","commonSituations":"Timeout too short for the RPC handshake; vtctld restarting mid-command; TLS/auth mismatch after the dial succeeded; request rejected by server version skew.","solutions":["Read the wrapped cause: if it's a deadline error, increase the context timeout for long-running vtctl commands","Check vtctld logs at the time of the call for server-side rejection reasons","Verify client/server Vitess versions are compatible (no RPC skew)","Retry the command once the server is confirmed stable; treat persistent failures as connectivity/TLS problems"],"exampleFix":"// before\nctx, cancel := context.WithTimeout(ctx, 5*time.Second)\n// after\nctx, cancel := context.WithTimeout(ctx, 60*time.Second) // long commands need more","handlingStrategy":"retry","validationCode":"if deadline, ok := ctx.Deadline(); ok && time.Until(deadline) < 30*time.Second {\n  ctx, _ = context.WithTimeout(context.WithoutCancel(ctx), 60*time.Second)\n}","typeGuard":null,"tryCatchPattern":"err := vtctlclient.RunCommandAndWait(ctx, server, args, recv, true)\nif err != nil && strings.Contains(err.Error(), \"cannot execute remote command\") {\n  log.Warn(\"remote exec failed\", slog.Any(\"error\", err))\n  // check server logs; retry only if cause is transient (Unavailable)\n}","preventionTips":["Size context timeouts to the command's expected duration","Confirm vtctld stability (no restarts) before long commands","Keep client and server Vitess versions within one release"],"tags":["go","network","grpc","vtctl","rpc"],"backgroundTag":"rpc-call-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}