MCPcopy
hub / github.com/pingcap/tidb / tidbSetPDClientForGC

Function tidbSetPDClientForGC

dumpling/export/dump.go:1448–1473  ·  view source on GitHub ↗

tidbSetPDClientForGC is an initialization step of Dumper.

(d *Dumper)

Source from the content-addressed store, hash-verified

1446
1447// tidbSetPDClientForGC is an initialization step of Dumper.
1448func tidbSetPDClientForGC(d *Dumper) error {
1449 tctx, si, pool := d.tctx, d.conf.ServerInfo, d.dbHandle
1450 if si.ServerType != version.ServerTypeTiDB ||
1451 si.ServerVersion == nil ||
1452 si.ServerVersion.Compare(*gcSafePointVersion) < 0 {
1453 return nil
1454 }
1455 pdAddrs, err := GetPdAddrs(tctx, pool)
1456 if err != nil {
1457 tctx.L().Info("meet some problem while fetching pd addrs. This won't affect dump process", log.ShortError(err))
1458 return nil
1459 }
1460 if len(pdAddrs) > 0 {
1461 doPdGC, err := checkSameCluster(tctx, pool, pdAddrs)
1462 if err != nil {
1463 tctx.L().Info("meet error while check whether fetched pd addr and TiDB belong to one cluster. This won't affect dump process", log.ShortError(err), zap.Strings("pdAddrs", pdAddrs))
1464 } else if doPdGC {
1465 pdClient, err := pd.NewClientWithContext(tctx, pdAddrs, pd.SecurityOption{})
1466 if err != nil {
1467 tctx.L().Info("create pd client to control GC failed. This won't affect dump process", log.ShortError(err), zap.Strings("pdAddrs", pdAddrs))
1468 }
1469 d.tidbPDClientForGC = pdClient
1470 }
1471 }
1472 return nil
1473}
1474
1475// tidbGetSnapshot is an initialization step of Dumper.
1476func tidbGetSnapshot(d *Dumper) error {

Callers

nothing calls this directly

Calls 5

ShortErrorFunction · 0.92
GetPdAddrsFunction · 0.85
checkSameClusterFunction · 0.85
CompareMethod · 0.65
LMethod · 0.45

Tested by

no test coverage detected