{"record":{"id":"ddf01e4b3a029430","repo":"vitessio/vitess","slug":"v-w-output-v","errorCode":null,"errorMessage":"%v: %w, output: %v","messagePattern":"(.+?): %w, output: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/mysqlctl/mysqld.go","lineNumber":1271,"sourceCode":"\n// execCmdWithContext searches the PATH for a command and runs it, logging the\n// output. If input is not nil, pipe it to the command's stdin. If ctx is\n// cancelled or its deadline passes, the command is killed and the call returns\n// promptly rather than blocking on a stalled process.\nfunc execCmdWithContext(ctx context.Context, name string, args, env []string, dir string, input io.Reader) (cmd *exec.Cmd, output string, err error) {\n\tcmdPath, _ := exec.LookPath(name)\n\n\tcmd = exec.CommandContext(ctx, cmdPath, args...)\n\tcmd.Env = env\n\tcmd.Dir = dir\n\tif input != nil {\n\t\tcmd.Stdin = input\n\t}\n\tout, err := cmd.CombinedOutput()\n\toutput = string(out)\n\tif err != nil {\n\t\tlog.Error(fmt.Sprintf(\"execCmd: %v failed: %v\", name, err))\n\t\terr = fmt.Errorf(\"%v: %w, output: %v\", name, err, output)\n\t}\n\treturn cmd, output, err\n}\n\n// binaryPath does a limited path lookup for a command,\n// searching only within sbin and bin in the given root.\nfunc binaryPath(root, binary string) (string, error) {\n\tnoSocketFile()\n\tsubdirs := []string{\"sbin\", \"bin\", \"libexec\", \"scripts\"}\n\tfor _, subdir := range subdirs {\n\t\tbinPath := path.Join(root, subdir, binary)\n\t\tif _, err := os.Stat(binPath); err == nil {\n\t\t\treturn binPath, nil\n\t\t}\n\t}\n\treturn \"\", fmt.Errorf(\"%s not found in any of %s/{%s}\",\n\t\tbinary, root, strings.Join(subdirs, \",\"))\n}","sourceCodeStart":1253,"sourceCodeEnd":1289,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/mysqlctl/mysqld.go#L1253-L1289","documentation":"execCmd runs an external command and captures combined stdout/stderr. If the command exits non-zero, the raw exec error is logged and then wrapped as '<command>: <exec error>, output: <combined output>' so operators can see exactly what the subprocess printed. This is a generic wrapper for failures of any external binary mysqlctl invokes (mysqld_safe, mysqladmin, mysqlinstall_db, etc.).","triggerScenarios":"Any execCmd call (e.g. launching mysqld, running mysqladmin shutdown, initialize scripts) where the spawned binary exits non-zero — the command name, underlying error, and its combined output are wrapped into the returned error.","commonSituations":"mysqld fails to start due to a bad my.cnf; mysqladmin fails authentication; required binaries missing or wrong version in the vt root bin/sbin dirs; disk full so the data directory cannot be initialized.","solutions":["Read the 'output:' portion of the error — it contains the child process's own diagnostic (e.g. mysqld's config error).","Fix the specific issue reported by the child (my.cnf directive, permissions, data dir state).","Verify the binary exists in the expected root bin/sbin directory and matches the expected MySQL flavor/version.","Check disk space and inode availability on the data/log directories."],"exampleFix":"// before: mysqld_safe exits, output shows unknown variable\n[ERROR] mysqld: unknown variable 'innodb_fake=1'\n// after: remove the bad directive from my.cnf\ninnodb_flush_method = O_DIRECT","handlingStrategy":"try-catch","validationCode":"out, err := exec.Command(name, args...).CombinedOutput()\nif err != nil {\n    log.Errorf(\"%s failed: %v, output: %s\", name, err, out)\n}","typeGuard":"func isCmdError(err error, cmdName string) bool {\n    return err != nil && strings.HasPrefix(err.Error(), cmdName+\":\")\n}","tryCatchPattern":"cmd, output, err := execCmd(ctx, 10*time.Second, \"mysqld\", args...)\nif err != nil {\n    // output holds the child's own diagnostics; surface it to operators\n    return fmt.Errorf(\"mysqld launch failed: %w (output: %s)\", err, output)\n}","preventionTips":["Always read the 'output:' segment of the wrapped error before debugging further.","Validate my.cnf and binary versions in CI before deploy.","Check disk space/inodes on data and log volumes.","Pin MySQL binary versions so flags match the server flavor."],"tags":["mysql","exec","subprocess","mysqld","mysqlctl"],"backgroundTag":"subprocess-exited-nonzero","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}