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

Upgrade TiCDC before TiKV and PD when cluster is equal or greater than v5.1.0 #2253

Merged
merged 5 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion components/dm/spec/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ func (topo *Specification) ComponentsByStartOrder() (comps []Component) {
}

// ComponentsByUpdateOrder return component in the order need to be updated.
func (topo *Specification) ComponentsByUpdateOrder() (comps []Component) {
func (topo *Specification) ComponentsByUpdateOrder(curVer string) (comps []Component) {
// "dm-master", "dm-worker"
comps = append(comps, &DMMasterComponent{topo})
comps = append(comps, &DMWorkerComponent{topo})
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/manager/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func checkSystemInfo(

roleFilter := set.NewStringSet(gOpt.Roles...)
nodeFilter := set.NewStringSet(gOpt.Nodes...)
components := topo.ComponentsByUpdateOrder()
components := topo.ComponentsByStartOrder()
components = operator.FilterComponent(components, roleFilter)

for _, comp := range components {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/manager/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Do you want to continue? [y/N]:`,
}

hasImported := false
for _, comp := range topo.ComponentsByUpdateOrder() {
for _, comp := range topo.ComponentsByUpdateOrder(base.Version) {
for _, inst := range comp.Instances() {
compName := inst.ComponentName()

Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/operation/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func Upgrade(
) error {
roleFilter := set.NewStringSet(options.Roles...)
nodeFilter := set.NewStringSet(options.Nodes...)
components := topo.ComponentsByUpdateOrder()
components := topo.ComponentsByUpdateOrder(currentVersion)
components = FilterComponent(components, roleFilter)
logger := ctx.Value(logprinter.ContextKeyLogger).(*logprinter.Logger)

Expand Down
16 changes: 12 additions & 4 deletions pkg/cluster/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ type Topology interface {
// Instances() []Instance
ComponentsByStartOrder() []Component
ComponentsByStopOrder() []Component
ComponentsByUpdateOrder() []Component
ComponentsByUpdateOrder(curVer string) []Component
IterInstance(fn func(instance Instance), concurrency ...int)
GetMonitoredOptions() *MonitoredOptions
// count how many time a path is used by instances in cluster
Expand Down Expand Up @@ -728,16 +728,24 @@ func (s *Specification) ComponentsByStartOrder() (comps []Component) {
}

// ComponentsByUpdateOrder return component in the order need to be updated.
func (s *Specification) ComponentsByUpdateOrder() (comps []Component) {
// "tiflash", "pd", "dashboard", "tikv", "pump", "tidb", "drainer", "cdc", "prometheus", "grafana", "alertmanager"
func (s *Specification) ComponentsByUpdateOrder(curVer string) (comps []Component) {
// Ref: https://github.com/pingcap/tiup/issues/2166
cdcUpgradeBeforePDTiKV := tidbver.TiCDCUpgradeBeforePDTiKV(curVer)

// "tiflash", <"cdc">, "pd", "dashboard", "tikv", "pump", "tidb", "drainer", <"cdc>", "prometheus", "grafana", "alertmanager"
comps = append(comps, &TiFlashComponent{s})
if cdcUpgradeBeforePDTiKV {
comps = append(comps, &CDCComponent{s})
}
comps = append(comps, &PDComponent{s})
comps = append(comps, &DashboardComponent{s})
comps = append(comps, &TiKVComponent{s})
comps = append(comps, &PumpComponent{s})
comps = append(comps, &TiDBComponent{s})
comps = append(comps, &DrainerComponent{s})
comps = append(comps, &CDCComponent{s})
if !cdcUpgradeBeforePDTiKV {
comps = append(comps, &CDCComponent{s})
}
comps = append(comps, &MonitorComponent{s})
comps = append(comps, &GrafanaComponent{s})
comps = append(comps, &AlertManagerComponent{s})
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/spec/spec_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (t *TestTopology) ComponentsByStopOrder() []Component {
return nil
}

func (t *TestTopology) ComponentsByUpdateOrder() []Component {
func (t *TestTopology) ComponentsByUpdateOrder(curVer string) []Component {
return nil
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/tidbver/tidbver.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ func TiCDCSupportRollingUpgrade(version string) bool {
return semver.Compare(version, "v6.3.0") >= 0 || strings.Contains(version, "nightly")
}

// TiCDCUpgradeBeforePDTiKV return if the given version of TiCDC should upgrade TiCDC before PD and TiKV
func TiCDCUpgradeBeforePDTiKV(version string) bool {
KanShiori marked this conversation as resolved.
Show resolved Hide resolved
return semver.Compare(version, "v5.1.0") >= 0 || strings.Contains(version, "nightly")
}

// NgMonitorDeployByDefault return if given version of TiDB cluster should contain ng-monitoring
func NgMonitorDeployByDefault(version string) bool {
return semver.Compare(version, "v5.4.0") >= 0 || strings.Contains(version, "nightly")
Expand Down
Loading