Skip to content

Commit

Permalink
MB-61981 - Even partition distribution after failover-recovery
Browse files Browse the repository at this point in the history
This PR accounts for even partition distribution across node
after a failover-recovery by
1. accounting for the recovery plans of only the index being
balanced
2. updating the plans passed to blance with the plans from
previous rebalance iterations.

Change-Id: I538f27f36061674dadb4094116211ef2fd2d9cff
Reviewed-on: https://review.couchbase.org/c/cbgt/+/210386
Well-Formed: Build Bot <[email protected]>
Well-Formed: Restriction Checker
Tested-by: Aditi Ahuja <[email protected]>
Reviewed-by: Abhi Dangeti <[email protected]>
  • Loading branch information
metonymic-smokey committed Jul 3, 2024
1 parent 5cd7839 commit 3ca19a7
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions rebalance/rebalance.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,15 @@ func (r *Rebalancer) calcBegEndMaps(indexDef *cbgt.IndexDef) (

var warnings map[string][]string
if r.recoveryPlanPIndexes != nil {
// PlanPIndexes for Index should include existing partitions placements.
// Use the recovery plans to initially populate the existing plans to
// provide context to blance.
for planName, plan := range r.recoveryPlanPIndexes.PlanPIndexes {
if plan.IndexUUID == indexDef.UUID {
r.existingPlanPIndexes.PlanPIndexes[planName] = plan
}
}

// During the failover, cbgt ignores the new nextMap from blance
// and just promotes the replica partitions to primary.
// Hence during the failover-recovery rebalance operation,
Expand All @@ -747,9 +756,10 @@ func (r *Rebalancer) calcBegEndMaps(indexDef *cbgt.IndexDef) (
// same set of nodes and the original planPIndexes.
r.Logf(" calcBegEndMaps: recovery rebalance for index: %s", indexDef.Name)
warnings = cbgt.BlancePlanPIndexes("", indexDef,
endPlanPIndexesForIndex, r.recoveryPlanPIndexes,
r.nodesAll, []string{}, r.nodesToRemove,
endPlanPIndexesForIndex, r.existingPlanPIndexes,
r.nodesAll, r.nodesToAdd, r.nodesToRemove,
r.nodeWeights, r.nodeHierarchy, false)

} else {
var enablePartitionNodeStickiness bool
if r.optionsReb.Manager != nil {
Expand Down Expand Up @@ -780,12 +790,12 @@ func (r *Rebalancer) calcBegEndMaps(indexDef *cbgt.IndexDef) (
endPlanPIndexesForIndex, r.existingPlanPIndexes,
r.nodesAll, r.nodesToAdd, r.nodesToRemove,
nodeWeights, r.nodeHierarchy, enablePartitionNodeStickiness)
}

// Updating this here since plans for index have been assigned to nodes.
// Will use this to pass context to blance.
for k, v := range endPlanPIndexesForIndex {
r.existingPlanPIndexes.PlanPIndexes[k] = v
}
// Updating this here since plans for index have been assigned to nodes.
// Will use this to pass context to blance.
for k, v := range endPlanPIndexesForIndex {
r.existingPlanPIndexes.PlanPIndexes[k] = v
}

for partitionName, partitionWarning := range warnings {
Expand Down

0 comments on commit 3ca19a7

Please sign in to comment.