{"record":{"id":"9172988df4dd40be","repo":"vitessio/vitess","slug":"postflight-mysqld-start-hook-failed-v","errorCode":null,"errorMessage":"postflight_mysqld_start hook failed: %v","messagePattern":"postflight_mysqld_start hook failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/mysqlctl/mysqld.go","lineNumber":608,"sourceCode":"\n\t\t\t\tfor _, callback := range callbacks {\n\t\t\t\t\tcallback()\n\t\t\t\t}\n\t\t\t}\n\t\t}(mysqld.cancelWaitCmd)\n\t\tmysqld.mutex.Unlock()\n\tdefault:\n\t\t// hook failed, we report error\n\t\treturn fmt.Errorf(\"mysqld_start hook failed: %v\", hr.String())\n\t}\n\n\t// try the postflight mysqld start hook, if any\n\tswitch hr := hook.NewHook(\"postflight_mysqld_start\", mysqldArgs).Execute(); hr.ExitStatus {\n\tcase hook.HOOK_SUCCESS, hook.HOOK_DOES_NOT_EXIST:\n\t\t// hook exists and worked, or does not exist, we can keep going\n\tdefault:\n\t\t// hook failed, we report error\n\t\treturn fmt.Errorf(\"postflight_mysqld_start hook failed: %v\", hr.String())\n\t}\n\n\treturn nil\n}\n\nfunc cleanupLockfile(socket string, ts string) error {\n\tlockPath := socket + \".lock\"\n\tpid, err := os.ReadFile(lockPath)\n\tif errors.Is(err, os.ErrNotExist) {\n\t\tlog.Info(fmt.Sprintf(\"%v: no stale lock file at %s\", ts, lockPath))\n\t\t// If there's no lock file, we can early return here, nothing\n\t\t// to clean up then.\n\t\treturn nil\n\t} else if err != nil {\n\t\tlog.Error(fmt.Sprintf(\"%v: error checking if lock file exists: %v\", ts, err))\n\t\t// Any other errors here are unexpected.\n\t\treturn err\n\t}","sourceCodeStart":590,"sourceCodeEnd":626,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/mysqlctl/mysqld.go#L590-L626","documentation":"The postflight `postflight_mysqld_start` hook ran after mysqld was launched and returned a failing exit status. startNoWait surfaces this as an error even though the mysqld process itself may already be starting.","triggerScenarios":"Mysqld.Start/Init with a `postflight_mysqld_start` hook script present in the vthook directory that exits non-zero.","commonSituations":"Post-start validation hook (e.g. waiting for a specific log line) failing; hook script bug; hook timing out because mysqld is slow to initialize.","solutions":["Inspect hr.String() output in the error for the hook's log","Run the hook manually against the started mysqld to reproduce","Fix the hook script or make its checks more tolerant of startup latency","Remove the postflight hook if obsolete"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := mysqld.Start(ctx, cnf); err != nil && strings.Contains(err.Error(), \"postflight_mysqld_start hook failed\") {\n    // mysqld may already be starting; check health before treating as fatal\n    log.Errorf(\"postflight hook failed: %s\", err)\n}","preventionTips":["Keep postflight checks tolerant of startup latency","Log hook output for diagnosis","Test postflight hooks against slow cold starts","Remove obsolete hooks"],"tags":["hooks","mysqlctl","startup"],"backgroundTag":"hook-execution-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}