Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix moco#630 #90

Merged
merged 1 commit into from
Jan 9, 2024
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
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