Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/cmd/mysqlctld/mysqlctld.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func main() {
}
mysqld.OnTerm(onTermFunc)

err = mysqld.RefreshConfig()
err = mysqld.RefreshConfig(ctx)
if err != nil {
log.Errorf("failed to refresh config: %v", err)
exit.Return(1)
Expand Down
2 changes: 1 addition & 1 deletion go/vt/mysqlctl/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func backup(ctx context.Context, mysqld MysqlDaemon, logger logutil.Logger, bh b
usable := backupErr == nil

// Try to restart mysqld
err = mysqld.RefreshConfig()
err = mysqld.RefreshConfig(ctx)
if err != nil {
return usable, fmt.Errorf("can't refresh mysqld config: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion go/vt/mysqlctl/fakemysqldaemon/fakemysqldaemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (fmd *FakeMysqlDaemon) ReinitConfig(ctx context.Context) error {
}

// RefreshConfig is part of the MysqlDaemon interface
func (fmd *FakeMysqlDaemon) RefreshConfig() error {
func (fmd *FakeMysqlDaemon) RefreshConfig(ctx context.Context) error {
return nil
}

Expand Down
8 changes: 8 additions & 0 deletions go/vt/mysqlctl/grpcmysqlctlclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ func (c *client) ReinitConfig(ctx context.Context) error {
})
}

// RefreshConfig is part of the MysqlctlClient interface.
func (c *client) RefreshConfig(ctx context.Context) error {
return c.withRetry(ctx, func() error {
_, err := c.c.RefreshConfig(ctx, &mysqlctlpb.RefreshConfigRequest{})
return err
})
}

// Close is part of the MysqlctlClient interface.
func (c *client) Close() {
c.cc.Close()
Expand Down
5 changes: 5 additions & 0 deletions go/vt/mysqlctl/grpcmysqlctlserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ func (s *server) ReinitConfig(ctx context.Context, request *mysqlctlpb.ReinitCon
return &mysqlctlpb.ReinitConfigResponse{}, s.mysqld.ReinitConfig(ctx)
}

// RefreshConfig implements the server side of the MysqlctlClient interface.
func (s *server) RefreshConfig(ctx context.Context, request *mysqlctlpb.RefreshConfigRequest) (*mysqlctlpb.RefreshConfigResponse, error) {
return &mysqlctlpb.RefreshConfigResponse{}, s.mysqld.RefreshConfig(ctx)
}

// StartServer registers the Server for RPCs.
func StartServer(s *grpc.Server, mysqld *mysqlctl.Mysqld) {
mysqlctlpb.RegisterMysqlCtlServer(s, &server{mysqld})
Expand Down
2 changes: 1 addition & 1 deletion go/vt/mysqlctl/mysql_daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type MysqlDaemon interface {
Shutdown(ctx context.Context, waitForMysqld bool) error
RunMysqlUpgrade() error
ReinitConfig(ctx context.Context) error
RefreshConfig() error
RefreshConfig(ctx context.Context) error
Wait(ctx context.Context) error

// GetMysqlPort returns the current port mysql is listening on.
Expand Down
3 changes: 3 additions & 0 deletions go/vt/mysqlctl/mysqlctlclient/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ type MysqlctlClient interface {
// ReinitConfig calls Mysqld.ReinitConfig remotely.
ReinitConfig(ctx context.Context) error

// RefreshConfig calls Mysqld.RefreshConfig remotely.
RefreshConfig(ctx context.Context) error

// Close will terminate the connection. This object won't be used anymore.
Close()
}
Expand Down
13 changes: 12 additions & 1 deletion go/vt/mysqlctl/mysqld.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,18 @@ func getMycnfTemplates(root string) []string {
// RefreshConfig attempts to recreate the my.cnf from templates, and log and
// swap in to place if it's updated. It keeps a copy of the last version in case fallback is required.
// Should be called from a stable replica, server_id is not regenerated.
func (mysqld *Mysqld) RefreshConfig() error {
func (mysqld *Mysqld) RefreshConfig(ctx context.Context) error {
// Execute as remote action on mysqlctld if requested.
if *socketFile != "" {
log.Infof("executing Mysqld.RefreshConfig() remotely via mysqlctld server: %v", *socketFile)
client, err := mysqlctlclient.New("unix", *socketFile)
if err != nil {
return fmt.Errorf("can't dial mysqlctld: %v", err)
}
defer client.Close()
return client.RefreshConfig(ctx)
}

log.Info("Checking for updates to my.cnf")
root, err := vtenv.VtRoot()
if err != nil {
Expand Down
94 changes: 74 additions & 20 deletions go/vt/proto/mysqlctl/mysqlctl.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions proto/mysqlctl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,15 @@ message ReinitConfigRequest{}

message ReinitConfigResponse{}

message RefreshConfigRequest{}

message RefreshConfigResponse{}

// MysqlCtl is the service definition
service MysqlCtl {
rpc Start(StartRequest) returns (StartResponse) {};
rpc Shutdown(ShutdownRequest) returns (ShutdownResponse) {};
rpc RunMysqlUpgrade(RunMysqlUpgradeRequest) returns (RunMysqlUpgradeResponse) {};
rpc ReinitConfig(ReinitConfigRequest) returns (ReinitConfigResponse) {};
rpc RefreshConfig(RefreshConfigRequest) returns (RefreshConfigResponse) {};
}
14 changes: 9 additions & 5 deletions test/tablet.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,15 @@ def start_vttablet(

# When vttablet restores from backup, it will re-generate the .cnf file.
# So we need to have EXTRA_MY_CNF set properly.
all_extra_my_cnf = get_all_extra_my_cnf(None)
if all_extra_my_cnf:
if not extra_env:
extra_env = {}
extra_env['EXTRA_MY_CNF'] = ':'.join(all_extra_my_cnf)
# When using mysqlctld, only mysqlctld should need EXTRA_MY_CNF.
# If any test fails without giving EXTRA_MY_CNF to vttablet,
# it means we missed some call that should run remotely on mysqlctld.
if not self.use_mysqlctld:
all_extra_my_cnf = get_all_extra_my_cnf(None)
if all_extra_my_cnf:
if not extra_env:
extra_env = {}
extra_env['EXTRA_MY_CNF'] = ':'.join(all_extra_my_cnf)

if extra_args:
args.extend(extra_args)
Expand Down