{"record":{"id":"8175c7a11f2308a0","repo":"vitessio/vitess","slug":"could-not-create-temp-file-v","errorCode":null,"errorMessage":"could not create temp file: %v","messagePattern":"could not create temp file: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/mysqlctl/mysqld.go","lineNumber":1570,"sourceCode":"// RefreshConfig attempts to recreate the my.cnf from templates, and log and\n// swap in to place if it's updated. It keeps a copy of the last version in case fallback is required.\n// Should be called from a stable replica, server_id is not regenerated.\nfunc (mysqld *Mysqld) RefreshConfig(ctx context.Context, cnf *Mycnf) error {\n\t// Execute as remote action on mysqlctld if requested.\n\tif socketFile != \"\" {\n\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) {","sourceCodeStart":1552,"sourceCodeEnd":1588,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/mysqlctl/mysqld.go#L1552-L1588","documentation":"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.","triggerScenarios":"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.","commonSituations":"VTDATAROOT directory deleted or never created; read-only filesystem; disk full; running as a user without write permission on the config directory.","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."],"exampleFix":"// before: directory missing\nls: /vt/vtdataroot/vt_0000000100: No such file or directory\n// after\nmkdir -p /vt/vtdataroot/vt_0000000100 && chown vitess:vitess /vt/vtdataroot/vt_0000000100","handlingStrategy":"validation","validationCode":"cfgDir := path.Dir(cnf.Path)\nif info, err := os.Stat(cfgDir); err != nil || !info.IsDir() {\n    return fmt.Errorf(\"config dir %s missing\", cfgDir)\n}\nif err := unix.Access(cfgDir, unix.W_OK); err != nil {\n    return fmt.Errorf(\"config dir %s not writable\", cfgDir)\n}","typeGuard":null,"tryCatchPattern":"if err := mysqld.RefreshConfig(ctx, cnf); err != nil {\n    if strings.Contains(err.Error(), \"could not create temp file\") {\n        log.Errorf(\"check disk space/permissions on %s: %v\", path.Dir(cnf.Path), err)\n    }\n    return err\n}","preventionTips":["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"],"tags":["filesystem","permissions","config"],"backgroundTag":"temp-file-creation-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}