{"record":{"id":"5c1c5aea40720951","repo":"vitessio/vitess","slug":"could-not-initconfig-in-v-v","errorCode":null,"errorMessage":"could not initConfig in %v: %v","messagePattern":"could not initConfig in (.+?): (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/mysqlctl/mysqld.go","lineNumber":1576,"sourceCode":"\t\tlog.Info(fmt.Sprintf(\"executing Mysqld.RefreshConfig() remotely via mysqlctld server: %v\", socketFile))\n\t\tclient, err := mysqlctlclient.New(ctx, \"unix\", socketFile)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"can't dial mysqlctld: %v\", err)\n\t\t}\n\t\tdefer client.Close()\n\t\treturn client.RefreshConfig(ctx)\n\t}\n\n\tlog.Info(\"Checking for updates to my.cnf\")\n\tf, err := os.CreateTemp(path.Dir(cnf.Path), \"my.cnf\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not create temp file: %v\", err)\n\t}\n\n\tdefer os.Remove(f.Name())\n\terr = mysqld.initConfig(cnf, f.Name())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not initConfig in %v: %v\", f.Name(), err)\n\t}\n\n\texisting, err := os.ReadFile(cnf.Path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not read existing file %v: %v\", cnf.Path, err)\n\t}\n\tupdated, err := os.ReadFile(f.Name())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not read updated file %v: %v\", f.Name(), err)\n\t}\n\n\tif bytes.Equal(existing, updated) {\n\t\tlog.Info(\"No changes to my.cnf. Continuing.\")\n\t\treturn nil\n\t}\n\n\tbackupPath := cnf.Path + \".previous\"\n\terr = os.Rename(cnf.Path, backupPath)","sourceCodeStart":1558,"sourceCodeEnd":1594,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/mysqlctl/mysqld.go#L1558-L1594","documentation":"RefreshConfig generated a candidate my.cnf in a temp file but mysqld.initConfig failed while filling the template. The message includes the temp file name and the underlying cause (template rendering or hook failure).","triggerScenarios":"Mysqld.RefreshConfig local path: mysqld.initConfig(cnf, f.Name()) returns error — e.g. the make_mycnf hook fails or cnf.makeMycnf/getMycnfTemplate rendering fails.","commonSituations":"Broken make_mycnf hook (see hook-failed error); missing my.cnf template files; invalid parameters (bad paths/ports) interpolated into the template.","solutions":["Look at the wrapped cause to see whether it is a hook failure or template error, and fix accordingly.","Verify my.cnf template files exist in vtenv (share/vitess/mycnf).","Check MysqldParams values (paths, ports, server ID) are valid.","Run the same initConfig path during tablet init to confirm it works there."],"exampleFix":"// before: missing template\n// vtenv/share/vitess/mycnf/templates.cnf deleted\n// after\n// restore template: git checkout -- config/mycnf/templates.cnf (or reinstall vitess files)","handlingStrategy":"try-catch","validationCode":"for _, tmpl := range []string{\"templates.cnf\"} {\n    if _, err := os.Stat(filepath.Join(vtenv.VtRoot(), \"share\", \"vitess\", \"mycnf\", tmpl)); err != nil {\n        return fmt.Errorf(\"my.cnf template missing: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := mysqld.RefreshConfig(ctx, cnf); err != nil {\n    if strings.Contains(err.Error(), \"could not initConfig\") {\n        log.Errorf(\"template/hook failure generating my.cnf: %v\", err)\n    }\n    return err\n}","preventionTips":["Verify vitess template files are installed intact in deployments","Validate MysqldParams (paths, ports, IDs) before refresh","Keep custom make_mycnf hooks tested and versioned with config changes","Run init once in staging to catch template regressions"],"tags":["config","mysql","template"],"backgroundTag":"config-render-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}