Skip to content

Commit

Permalink
Merge pull request #90 from cybozu-go/fix-630
Browse files Browse the repository at this point in the history
Fix moco#630
  • Loading branch information
ymmt2005 authored Jan 9, 2024
2 parents 1fa506c + e70dabe commit f1c4680
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion server/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"net"
"time"

mocoagent "github.com/cybozu-go/moco-agent"
Expand Down Expand Up @@ -56,7 +57,9 @@ func (a *Agent) Clone(ctx context.Context, req *proto.CloneRequest) error {
metrics.CloneDurationSeconds.Observe(time.Since(startTime).Seconds())
}()

donorAddr := fmt.Sprintf("%s:%d", req.Host, req.Port)
// Unfortunately, MySQL 8.0 does not support IPv6 address format.
// https://dev.mysql.com/doc/refman/8.0/en/clone-plugin-options-variables.html#sysvar_clone_valid_donor_list
donorAddr := net.JoinHostPort(req.Host, fmt.Sprint(req.Port))
if _, err := a.db.ExecContext(ctx, `SET GLOBAL clone_valid_donor_list = ?`, donorAddr); err != nil {
return status.Errorf(codes.Internal, "failed to set clone_valid_donor_list: %+v", err)
}
Expand Down
3 changes: 2 additions & 1 deletion server/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package server
import (
"errors"
"fmt"
"net"
"time"

mocoagent "github.com/cybozu-go/moco-agent"
Expand All @@ -15,7 +16,7 @@ func getMySQLConn(config MySQLAccessorConfig) (*sqlx.DB, error) {
conf.User = mocoagent.AgentUser
conf.Passwd = config.Password
conf.Net = "tcp"
conf.Addr = fmt.Sprintf("%s:%d", config.Host, config.Port)
conf.Addr = net.JoinHostPort(config.Host, fmt.Sprint(config.Port))
conf.Timeout = config.ConnectionTimeout
conf.ReadTimeout = config.ReadTimeout
conf.InterpolateParams = true
Expand Down

0 comments on commit f1c4680

Please sign in to comment.