Skip to content

Commit

Permalink
fetch pd version from leader intead of conf address (pingcap#11)
Browse files Browse the repository at this point in the history
Co-authored-by: rishabh_mittal <mittalrishabh@gmail.com>
  • Loading branch information
2 people authored and GitHub Enterprise committed Oct 11, 2023
1 parent c8e912e commit 223fa11
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions br/pkg/lightning/restore/checksum.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"context"
"database/sql"
"fmt"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -73,23 +72,15 @@ func newChecksumManager(ctx context.Context, rc *Controller, store kv.Storage) (
return nil, nil
}

pdAddr := rc.cfg.TiDB.PdAddr
pdVersion, err := pdutil.FetchPDVersion(ctx, rc.tls, pdAddr)
pdVersion, err := pdutil.FetchPDVersion(ctx, rc.tls, rc.pdCli.GetLeaderAddr())
if err != nil {
return nil, errors.Trace(err)
}

// for v4.0.0 or upper, we can use the gc ttl api
var manager ChecksumManager
if pdVersion.Major >= 4 {
tlsOpt := rc.tls.ToPDSecurityOption()
addrs := strings.Split(pdAddr, ",")
pdCli, err := pd.NewClientWithContext(ctx, addrs, tlsOpt)
if err != nil {
return nil, errors.Trace(err)
}

manager = newTiKVChecksumManager(store.GetClient(), pdCli, uint(rc.cfg.TiDB.DistSQLScanConcurrency))
manager = newTiKVChecksumManager(store.GetClient(), rc.pdCli, uint(rc.cfg.TiDB.DistSQLScanConcurrency))
} else {
db, err := rc.tidbGlue.GetDB()
if err != nil {
Expand Down

0 comments on commit 223fa11

Please sign in to comment.