vitessio/vitess · error

could not initConfig in

Error message

could not initConfig in %v: %v

What it means

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).

Solutions

  1. Look at the wrapped cause to see whether it is a hook failure or template error, and fix accordingly.
  2. Verify my.cnf template files exist in vtenv (share/vitess/mycnf).
  3. Check MysqldParams values (paths, ports, server ID) are valid.
  4. Run the same initConfig path during tablet init to confirm it works there.

Example fix

// before: missing template
// vtenv/share/vitess/mycnf/templates.cnf deleted
// after
// restore template: git checkout -- config/mycnf/templates.cnf (or reinstall vitess files)
Defensive patterns

Strategy: try-catch

Validate before calling

for _, tmpl := range []string{"templates.cnf"} {
    if _, err := os.Stat(filepath.Join(vtenv.VtRoot(), "share", "vitess", "mycnf", tmpl)); err != nil {
        return fmt.Errorf("my.cnf template missing: %w", err)
    }
}

Try / catch

if err := mysqld.RefreshConfig(ctx, cnf); err != nil {
    if strings.Contains(err.Error(), "could not initConfig") {
        log.Errorf("template/hook failure generating my.cnf: %v", err)
    }
    return err
}

Prevention

When it happens

Trigger: Mysqld.RefreshConfig local path: mysqld.initConfig(cnf, f.Name()) returns error — e.g. the make_mycnf hook fails or cnf.makeMycnf/getMycnfTemplate rendering fails.

Common situations: Broken make_mycnf hook (see hook-failed error); missing my.cnf template files; invalid parameters (bad paths/ports) interpolated into the template.

Related errors


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

Appendix: source

Thrown at go/vt/mysqlctl/mysqld.go:1576

		log.Info(fmt.Sprintf("executing Mysqld.RefreshConfig() remotely via mysqlctld server: %v", socketFile))
		client, err := mysqlctlclient.New(ctx, "unix", socketFile)
		if err != nil {
			return fmt.Errorf("can't dial mysqlctld: %v", err)
		}
		defer client.Close()
		return client.RefreshConfig(ctx)
	}

	log.Info("Checking for updates to my.cnf")
	f, err := os.CreateTemp(path.Dir(cnf.Path), "my.cnf")
	if err != nil {
		return fmt.Errorf("could not create temp file: %v", err)
	}

	defer os.Remove(f.Name())
	err = mysqld.initConfig(cnf, f.Name())
	if err != nil {
		return fmt.Errorf("could not initConfig in %v: %v", f.Name(), err)
	}

	existing, err := os.ReadFile(cnf.Path)
	if err != nil {
		return fmt.Errorf("could not read existing file %v: %v", cnf.Path, err)
	}
	updated, err := os.ReadFile(f.Name())
	if err != nil {
		return fmt.Errorf("could not read updated file %v: %v", f.Name(), err)
	}

	if bytes.Equal(existing, updated) {
		log.Info("No changes to my.cnf. Continuing.")
		return nil
	}

	backupPath := cnf.Path + ".previous"
	err = os.Rename(cnf.Path, backupPath)

View on GitHub (pinned to 01a25a7d17)