-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
lightning: fix pd http request using old address #45680
Changes from 6 commits
9b77e00
ab2a95d
759f138
b436b57
7db9ecb
bf57b6a
4a88031
f163612
721f71f
5ff5a07
f1db6c5
f2bf008
52a4250
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,6 +199,7 @@ type Controller struct { | |
engineMgr backend.EngineManager | ||
backend backend.Backend | ||
db *sql.DB | ||
pdCli pd.Client | ||
|
||
alterTableLock sync.Mutex | ||
sysVars map[string]string | ||
|
@@ -294,6 +295,10 @@ func NewImportControllerWithPauser( | |
if err != nil { | ||
return nil, err | ||
} | ||
pdCli, err := pd.NewClientWithContext(ctx, []string{cfg.TiDB.PdAddr}, tls.ToPDSecurityOption()) | ||
if err != nil { | ||
return nil, errors.Trace(err) | ||
} | ||
|
||
var cpdb checkpoints.DB | ||
// if CheckpointStorage is set, we should use given ExternalStorage to create checkpoints. | ||
|
@@ -349,7 +354,7 @@ func NewImportControllerWithPauser( | |
} | ||
|
||
if cfg.TikvImporter.DuplicateResolution != config.DupeResAlgNone { | ||
if err := tikv.CheckTiKVVersion(ctx, tls, cfg.TiDB.PdAddr, minTiKVVersionForDuplicateResolution, maxTiKVVersionForDuplicateResolution); err != nil { | ||
if err := tikv.CheckTiKVVersion(ctx, tls, pdCli.GetLeaderAddr(), minTiKVVersionForDuplicateResolution, maxTiKVVersionForDuplicateResolution); err != nil { | ||
if !berrors.Is(err, berrors.ErrVersionMismatch) { | ||
return nil, common.ErrCheckKVVersion.Wrap(err).GenWithStackByArgs() | ||
} | ||
|
@@ -410,7 +415,7 @@ func NewImportControllerWithPauser( | |
|
||
var wrapper backend.TargetInfoGetter | ||
if cfg.TikvImporter.Backend == config.BackendLocal { | ||
wrapper = local.NewTargetInfoGetter(tls, db, cfg.TiDB.PdAddr) | ||
wrapper = local.NewTargetInfoGetter(tls, db, pdCli) | ||
} else { | ||
wrapper = tidb.NewTargetInfoGetter(db) | ||
} | ||
|
@@ -449,6 +454,7 @@ func NewImportControllerWithPauser( | |
pauser: p.Pauser, | ||
engineMgr: backend.MakeEngineManager(backendObj), | ||
backend: backendObj, | ||
pdCli: pdCli, | ||
db: db, | ||
sysVars: common.DefaultImportantVariables, | ||
tls: tls, | ||
|
@@ -473,7 +479,7 @@ func NewImportControllerWithPauser( | |
preInfoGetter: preInfoGetter, | ||
precheckItemBuilder: preCheckBuilder, | ||
encBuilder: encodingBuilder, | ||
tikvModeSwitcher: local.NewTiKVModeSwitcher(tls, cfg.TiDB.PdAddr, log.FromContext(ctx).Logger), | ||
tikvModeSwitcher: local.NewTiKVModeSwitcher(tls, pdCli, log.FromContext(ctx).Logger), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. init another client for it? odd to have an object with close but not called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think creating two pd client is not effient and a bit confusing. pd has a background goroutine to update members. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can add a comment here, easy to be taken as a bug. and i think it's a bad practice to rely on |
||
|
||
keyspaceName: p.KeyspaceName, | ||
resourceGroupName: p.ResourceGroupName, | ||
|
@@ -1849,7 +1855,7 @@ func (rc *Controller) fullCompact(ctx context.Context) error { | |
} | ||
|
||
func (rc *Controller) doCompact(ctx context.Context, level int32) error { | ||
tls := rc.tls.WithHost(rc.cfg.TiDB.PdAddr) | ||
tls := rc.tls.WithHost(rc.pdCli.GetLeaderAddr()) | ||
return tikv.ForAllStores( | ||
ctx, | ||
tls, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not closed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other places too, seems not close anywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already addressed in f163612
PTAL again