Skip to content

Commit

Permalink
add support of multiple PD zones in lightning (pingcap#8)
Browse files Browse the repository at this point in the history
Co-authored-by: rishabh_mittal <[email protected]>
  • Loading branch information
2 people authored and GitHub Enterprise committed Sep 22, 2023
1 parent df39981 commit 52d8d15
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 1 addition & 4 deletions br/pkg/lightning/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1069,10 +1069,7 @@ func (cfg *Config) CheckAndAdjustTiDBPort(ctx context.Context, mustHaveInternalC
if cfg.TiDB.Port <= 0 {
cfg.TiDB.Port = int(settings.Port)
}
if len(cfg.TiDB.PdAddr) == 0 {
pdAddrs := strings.Split(settings.Path, ",")
cfg.TiDB.PdAddr = pdAddrs[0] // FIXME support multiple PDs once importer can.
}
cfg.TiDB.PdAddr = settings.Path
}

if cfg.TiDB.Port <= 0 {
Expand Down
4 changes: 3 additions & 1 deletion br/pkg/lightning/restore/checksum.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"context"
"database/sql"
"fmt"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -82,7 +83,8 @@ func newChecksumManager(ctx context.Context, rc *Controller, store kv.Storage) (
var manager ChecksumManager
if pdVersion.Major >= 4 {
tlsOpt := rc.tls.ToPDSecurityOption()
pdCli, err := pd.NewClientWithContext(ctx, []string{pdAddr}, tlsOpt)
addrs := strings.Split(pdAddr, ",")
pdCli, err := pd.NewClientWithContext(ctx, addrs, tlsOpt)
if err != nil {
return nil, errors.Trace(err)
}
Expand Down
6 changes: 4 additions & 2 deletions br/pkg/lightning/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ func NewRestoreControllerWithPauser(
if maxOpenFiles < 0 {
maxOpenFiles = math.MaxInt32
}
pdCli, err = pd.NewClientWithContext(ctx, []string{cfg.TiDB.PdAddr}, tls.ToPDSecurityOption())
addrs := strings.Split(cfg.TiDB.PdAddr, ",")
pdCli, err = pd.NewClientWithContext(ctx, addrs, tls.ToPDSecurityOption())
if err != nil {
return nil, errors.Trace(err)
}
Expand Down Expand Up @@ -1354,7 +1355,8 @@ const (

func (rc *Controller) keepPauseGCForDupeRes(ctx context.Context) (<-chan struct{}, error) {
tlsOpt := rc.tls.ToPDSecurityOption()
pdCli, err := pd.NewClientWithContext(ctx, []string{rc.pdCli.GetLeaderAddr()}, tlsOpt)
addrs := strings.Split(rc.cfg.TiDB.PdAddr, ",")
pdCli, err := pd.NewClientWithContext(ctx, addrs, tlsOpt)
if err != nil {
return nil, errors.Trace(err)
}
Expand Down

0 comments on commit 52d8d15

Please sign in to comment.