@@ -1313,6 +1313,14 @@ func (rs *rangeState) removePendingChangeTracking(changeID changeID) {
13131313 }
13141314}
13151315
1316+ func (rs * rangeState ) clearAnalyzedConstraints () {
1317+ if rs .constraints == nil {
1318+ return
1319+ }
1320+ releaseRangeAnalyzedConstraints (rs .constraints )
1321+ rs .constraints = nil
1322+ }
1323+
13161324// clusterState is the state of the cluster known to the allocator, including
13171325// adjustments based on pending changes. It does not include additional
13181326// indexing needed for constraint matching, or for tracking ranges that may
@@ -1662,8 +1670,7 @@ func (cs *clusterState) processStoreLeaseholderMsgInternal(
16621670 // assuming the leaseholder wouldn't have sent the message if there was no
16631671 // change, or we noticed a divergence in membership above and fell through
16641672 // here.
1665- releaseRangeAnalyzedConstraints (rs .constraints )
1666- rs .constraints = nil
1673+ rs .clearAnalyzedConstraints ()
16671674 }
16681675 // Remove ranges for which this is the localRangeOwner, but for which it is
16691676 // no longer the leaseholder.
@@ -1704,7 +1711,7 @@ func (cs *clusterState) processStoreLeaseholderMsgInternal(
17041711 }
17051712 delete (cs .stores [replica .StoreID ].adjusted .replicas , r )
17061713 }
1707- releaseRangeAnalyzedConstraints ( rs .constraints )
1714+ rs .clearAnalyzedConstraints ( )
17081715 delete (cs .ranges , r )
17091716 }
17101717 localss := cs .stores [msg .StoreID ]
@@ -1963,8 +1970,7 @@ func (cs *clusterState) undoPendingChange(cid changeID) {
19631970 panic (errors .AssertionFailedf ("pending change is marked as no-rollback" ))
19641971 }
19651972 // Wipe the analyzed constraints, as the range has changed.
1966- releaseRangeAnalyzedConstraints (rs .constraints )
1967- rs .constraints = nil
1973+ rs .clearAnalyzedConstraints ()
19681974 rs .lastFailedChange = cs .ts .Now ()
19691975 // Undo the change delta as well as the replica change and remove the pending
19701976 // change from all tracking (range, store, cluster).
0 commit comments