{"record":{"id":"7863f77fdb6fa0c1","repo":"vitessio/vitess","slug":"could-not-move-v-to-v-v","errorCode":null,"errorMessage":"could not move %v to %v: %v","messagePattern":"could not move (.+?) to (.+?): (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"go/vt/mysqlctl/mysqld.go","lineNumber":1600,"sourceCode":"\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 {\n\t\treturn fmt.Errorf(\"could not move %v to %v: %v\", f.Name(), cnf.Path, err)\n\t}\n\tlog.Info(fmt.Sprintf(\"Updated my.cnf. Backup of previous version available in %v\", backupPath))\n\n\treturn nil\n}\n\n// ReinitConfig updates the config file as if Mysqld is initializing. At the\n// moment it only randomizes ServerID because it's not safe to restore a replica\n// from a backup and then give it the same ServerID as before, MySQL can then\n// skip transactions in the replication stream with the same server_id.\nfunc (mysqld *Mysqld) ReinitConfig(ctx context.Context, cnf *Mycnf) error {\n\tlog.Info(\"Mysqld.ReinitConfig\")\n\n\t// Execute as remote action on mysqlctld if requested.\n\tif socketFile != \"\" {\n\t\tlog.Info(fmt.Sprintf(\"executing Mysqld.ReinitConfig() remotely via mysqlctld server: %v\", socketFile))\n\t\tclient, err := mysqlctlclient.New(ctx, \"unix\", socketFile)\n\t\tif err != nil {","sourceCodeStart":1582,"sourceCodeEnd":1618,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/mysqlctl/mysqld.go#L1582-L1618","documentation":"After successfully backing up the old my.cnf to my.cnf.previous, RefreshConfig failed to rename the freshly generated temp config into place. This leaves the config dir in a state where my.cnf is absent and the new config remains as the temp file (backup already succeeded).","triggerScenarios":"Mysqld.RefreshConfig: os.Rename(f.Name(), cnf.Path) fails immediately after the backup rename succeeded — temp file removed concurrently, or filesystem/device mismatch preventing rename.","commonSituations":"Disk/full or read-only filesystem flip; concurrent cleanup deleting the temp file between the two renames; overlay/fuse filesystem with quirky rename semantics.","solutions":["Manually recover: mv <cnf.Path>.previous back or copy the temp file to cnf.Path.","Check filesystem health, free space, and writability of the config directory.","Eliminate concurrent processes that could delete the temp file during refresh.","Re-run RefreshConfig once the filesystem issue is resolved."],"exampleFix":"// before: my.cnf missing after failed rename\nls my.cnf -> No such file\n// after\nmv my.cnf.previous my.cnf   # or: mv /vt/vtdataroot/vt_0000000100/my.cnfXXXX my.cnf","handlingStrategy":"try-catch","validationCode":"if unix.Access(path.Dir(cnf.Path), unix.W_OK) != nil {\n    return fmt.Errorf(\"cannot complete refresh: %s not writable\", path.Dir(cnf.Path))\n}","typeGuard":null,"tryCatchPattern":"if err := mysqld.RefreshConfig(ctx, cnf); err != nil {\n    if strings.Contains(err.Error(), \"could not move\") {\n        // config dir is now inconsistent: my.cnf renamed away, temp remains\n        log.Errorf(\"recover: restore %s.previous or move temp file into place\", cnf.Path)\n    }\n    return err\n}","preventionTips":["Monitor free space and mount state on tablet hosts","Prevent concurrent cleaners from touching the config dir","Have a runbook to restore my.cnf from my.cnf.previous","Prefer overlay-free (ext4/xfs) filesystems for VTDATAROOT"],"tags":["filesystem","rename","recovery"],"backgroundTag":"file-rename-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}