{"record":{"id":"b9ca5f0231df91fe","repo":"vitessio/vitess","slug":"could-not-read-existing-file-v-v","errorCode":null,"errorMessage":"could not read existing file %v: %v","messagePattern":"could not read existing file (.+?): (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/mysqlctl/mysqld.go","lineNumber":1581,"sourceCode":"\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)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not back up existing %v: %v\", cnf.Path, err)\n\t}\n\terr = os.Rename(f.Name(), cnf.Path)\n\tif err != nil {","sourceCodeStart":1563,"sourceCodeEnd":1599,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/mysqlctl/mysqld.go#L1563-L1599","documentation":"Returned by mysqld config update logic when the existing (current) config file on disk cannot be read before applying updates, wrapping the I/O error.","triggerScenarios":"Mysqld.RefreshConfig after successfully writing the temp config: os.ReadFile(cnf.Path) fails because my.cnf was deleted, moved, or has bad permissions.","commonSituations":"First-time refresh before my.cnf ever written in an unexpected code path; manual cleanup removed my.cnf; tablet directory partially deleted; user running refresh differs from owner of my.cnf.","solutions":["Verify cnf.Path exists and is readable by the current user.","If my.cnf was intentionally removed, reinitialize the tablet config instead of refreshing.","Fix permissions: chown/chmod the my.cnf file.","Point cnf.Path at the correct config location for this tablet."],"exampleFix":"// before\nrm /vt/vtdataroot/vt_0000000100/my.cnf  # then RefreshConfig fails\n// after\nvttablet reinit (or restore my.cnf from my.cnf.previous) before refreshing","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(cnf.Path); err != nil {\n    return fmt.Errorf(\"existing my.cnf %s missing; reinit required before refresh\", cnf.Path)\n}","typeGuard":null,"tryCatchPattern":"if err := mysqld.RefreshConfig(ctx, cnf); err != nil {\n    if strings.Contains(err.Error(), \"could not read existing file\") {\n        log.Errorf(\"my.cnf absent/unreadable at %s; reinitialize config\", cnf.Path)\n    }\n    return err\n}","preventionTips":["Never hand-delete my.cnf from a running tablet directory","Back up via the built-in my.cnf.previous mechanism instead of rm","Keep tablet dir ownership consistent with the running user","Reinitialize config after manual cleanup of VTDATAROOT"],"tags":["filesystem","config","permissions"],"backgroundTag":"file-not-found","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}