Skip to content

Commit

Permalink
Address PR comment
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo J. Ortega U <5791035+ejortegau@users.noreply.github.com>
  • Loading branch information
ejortegau committed Nov 5, 2024
1 parent e315d12 commit 3405351
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go/vt/vtctl/reparentutil/emergency_reparenter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2872,7 +2872,7 @@ func TestEmergencyReparenter_findMostAdvanced(t *testing.T) {
validCandidates: map[string]replication.Position{
"zone1-0000000100": positionMostAdvanced,
"zone1-0000000101": positionIntermediate1,
"zone1-0000000102": positionIntermediate2,
"zone1-0000000102": positionMostAdvanced,
},
tabletMap: map[string]*topo.TabletInfo{
"zone1-0000000100": {
Expand Down
16 changes: 8 additions & 8 deletions go/vt/vtctl/reparentutil/reparent_sorter.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,6 @@ func (rs *reparentSorter) Less(i, j int) bool {
return true
}

// We want tablets which are currently running a backup to always be at the end of the list, so that's the first thing we check
if !rs.backupRunning[topoproto.TabletAliasString(rs.tablets[i].Alias)] && rs.backupRunning[topoproto.TabletAliasString(rs.tablets[j].Alias)] {
return true
}
if rs.backupRunning[topoproto.TabletAliasString(rs.tablets[i].Alias)] && !rs.backupRunning[topoproto.TabletAliasString(rs.tablets[j].Alias)] {
return false
}

if !rs.positions[i].AtLeast(rs.positions[j]) {
// [i] does not have all GTIDs that [j] does
return false
Expand All @@ -96,6 +88,14 @@ func (rs *reparentSorter) Less(i, j int) bool {
jPromotionRule := PromotionRule(rs.durability, rs.tablets[j])
iPromotionRule := PromotionRule(rs.durability, rs.tablets[i])

// We want tablets which are currently running a backup to always be at the end of the list, so that's the first thing we check
if !rs.backupRunning[topoproto.TabletAliasString(rs.tablets[i].Alias)] && rs.backupRunning[topoproto.TabletAliasString(rs.tablets[j].Alias)] {
return true
}
if rs.backupRunning[topoproto.TabletAliasString(rs.tablets[i].Alias)] && !rs.backupRunning[topoproto.TabletAliasString(rs.tablets[j].Alias)] {
return false
}

// If the promotion rules are different then we want to sort by the promotion rules.
if len(rs.innodbBufferPool) != 0 && jPromotionRule == iPromotionRule {
if rs.innodbBufferPool[i] > rs.innodbBufferPool[j] {
Expand Down

0 comments on commit 3405351

Please sign in to comment.