Skip to content

Commit

Permalink
go/vt/mysqlctl: add preflight_mysqld_shutdown hook
Browse files Browse the repository at this point in the history
Signed-off-by: Max Englander <[email protected]>
  • Loading branch information
maxenglander committed Jan 29, 2025
1 parent 39a0ddd commit f2fed30
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions go/vt/mysqlctl/mysqld.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,10 +624,21 @@ func (mysqld *Mysqld) Shutdown(ctx context.Context, cnf *Mycnf, waitForMysqld bo
return nil
}

// try the mysqld shutdown hook, if any
h := hook.NewSimpleHook("mysqld_shutdown")
// try the preflight mysqld shutdown hook, if any
h := hook.NewSimpleHook("preflight_mysqld_shutdown")
hr := h.ExecuteContext(ctx)
switch hr.ExitStatus {
case hook.HOOK_SUCCESS, hook.HOOK_DOES_NOT_EXIST:
// hook exists and worked, or else does not exist.
default:
// hook failed, we report error
return fmt.Errorf("preflight_mysqld_shutdown hook failed: %v", hr.String())
}

// try the mysqld shutdown hook, if any
h = hook.NewSimpleHook("mysqld_shutdown")
hr = h.ExecuteContext(ctx)
switch hr.ExitStatus {
case hook.HOOK_SUCCESS:
// hook exists and worked, we can keep going
case hook.HOOK_DOES_NOT_EXIST:
Expand Down

0 comments on commit f2fed30

Please sign in to comment.