vitessio/vitess · error
could not create temp file: %v
Error message
could not create temp file: %v
What it means
During a local RefreshConfig, os.CreateTemp failed to create a temporary my.cnf in the directory containing the current my.cnf. The error is wrapped from the OS and indicates filesystem-level inability to write in that directory.
Source
Thrown at go/vt/mysqlctl/mysqld.go:1570
// RefreshConfig attempts to recreate the my.cnf from templates, and log and
// swap in to place if it's updated. It keeps a copy of the last version in case fallback is required.
// Should be called from a stable replica, server_id is not regenerated.
func (mysqld *Mysqld) RefreshConfig(ctx context.Context, cnf *Mycnf) error {
// Execute as remote action on mysqlctld if requested.
if socketFile != "" {
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) {View on GitHub (pinned to 01a25a7d17)
Solutions
- Check the directory containing cnf.Path exists, is writable, and the disk is not full.
- Recreate the vt tablet directory structure (init config) if VTDATAROOT was wiped.
- Fix ownership/permissions: chown to the user running vitess.
- Ensure the filesystem is mounted read-write.
Example fix
// before: directory missing ls: /vt/vtdataroot/vt_0000000100: No such file or directory // after mkdir -p /vt/vtdataroot/vt_0000000100 && chown vitess:vitess /vt/vtdataroot/vt_0000000100
Defensive patterns
Strategy: validation
Validate before calling
cfgDir := path.Dir(cnf.Path)
if info, err := os.Stat(cfgDir); err != nil || !info.IsDir() {
return fmt.Errorf("config dir %s missing", cfgDir)
}
if err := unix.Access(cfgDir, unix.W_OK); err != nil {
return fmt.Errorf("config dir %s not writable", cfgDir)
} Try / catch
if err := mysqld.RefreshConfig(ctx, cnf); err != nil {
if strings.Contains(err.Error(), "could not create temp file") {
log.Errorf("check disk space/permissions on %s: %v", path.Dir(cnf.Path), err)
}
return err
} Prevention
- Ensure VTDATAROOT directory tree is provisioned before tablet start
- Monitor disk usage and inode exhaustion on tablet hosts
- Run all vitess processes as the same service user
- Mount tablet data dirs read-write and verify in startup scripts
When it happens
Trigger: Mysqld.RefreshConfig running locally (no mysqlctld socket); os.CreateTemp(path.Dir(cnf.Path), "my.cnf") fails due to missing directory, full disk, or permission denied.
Common situations: VTDATAROOT directory deleted or never created; read-only filesystem; disk full; running as a user without write permission on the config directory.
Related errors
- could not read existing file %v: %v
- cannot stat hook %v: %v
- unable to create file: %v
- could not back up existing %v: %v
- failure creating directory %s: %w
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/8175c7a11f2308a0.
Report an issue: GitHub.