vitessio/vitess · error

postflight_mysqld_start hook failed: %v

Error message

postflight_mysqld_start hook failed: %v

What it means

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.

Source

Thrown at go/vt/mysqlctl/mysqld.go:608

				for _, callback := range callbacks {
					callback()
				}
			}
		}(mysqld.cancelWaitCmd)
		mysqld.mutex.Unlock()
	default:
		// hook failed, we report error
		return fmt.Errorf("mysqld_start hook failed: %v", hr.String())
	}

	// try the postflight mysqld start hook, if any
	switch hr := hook.NewHook("postflight_mysqld_start", mysqldArgs).Execute(); hr.ExitStatus {
	case hook.HOOK_SUCCESS, hook.HOOK_DOES_NOT_EXIST:
		// hook exists and worked, or does not exist, we can keep going
	default:
		// hook failed, we report error
		return fmt.Errorf("postflight_mysqld_start hook failed: %v", hr.String())
	}

	return nil
}

func cleanupLockfile(socket string, ts string) error {
	lockPath := socket + ".lock"
	pid, err := os.ReadFile(lockPath)
	if errors.Is(err, os.ErrNotExist) {
		log.Info(fmt.Sprintf("%v: no stale lock file at %s", ts, lockPath))
		// If there's no lock file, we can early return here, nothing
		// to clean up then.
		return nil
	} else if err != nil {
		log.Error(fmt.Sprintf("%v: error checking if lock file exists: %v", ts, err))
		// Any other errors here are unexpected.
		return err
	}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Inspect hr.String() output in the error for the hook's log
  2. Run the hook manually against the started mysqld to reproduce
  3. Fix the hook script or make its checks more tolerant of startup latency
  4. Remove the postflight hook if obsolete
Defensive patterns

Strategy: try-catch

Try / catch

if err := mysqld.Start(ctx, cnf); err != nil && strings.Contains(err.Error(), "postflight_mysqld_start hook failed") {
    // mysqld may already be starting; check health before treating as fatal
    log.Errorf("postflight hook failed: %s", err)
}

Prevention

When it happens

Trigger: Mysqld.Start/Init with a `postflight_mysqld_start` hook script present in the vthook directory that exits non-zero.

Common situations: 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.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/9172988df4dd40be. Report an issue: GitHub.