@@ -147,17 +147,8 @@ impl ClickhouseAllocator {
147147 return bump_gen_if_necessary ( new_config) ;
148148 } ;
149149
150- // Save the log index for next time if it's been incremented
151- let inventory_updated = if inventory_membership
152- . leader_committed_log_index
153- > self . parent_config . highest_seen_keeper_leader_committed_log_index
154- {
155- new_config. highest_seen_keeper_leader_committed_log_index =
156- inventory_membership. leader_committed_log_index ;
157- true
158- } else {
159- false
160- } ;
150+ let inventory_updated = inventory_membership. leader_committed_log_index
151+ > self . parent_config . highest_seen_keeper_leader_committed_log_index ;
161152
162153 if current_keepers != inventory_membership. raft_config {
163154 // We know that there is a reconfiguration in progress. If there has
@@ -167,6 +158,12 @@ impl ClickhouseAllocator {
167158 return bump_gen_if_necessary ( new_config) ;
168159 }
169160
161+ // Save the log index from inventory because we are going to
162+ // need to use it to see if inventory has changed next time
163+ // through the planner.
164+ new_config. highest_seen_keeper_leader_committed_log_index =
165+ inventory_membership. leader_committed_log_index ;
166+
170167 // We're still trying to reach our desired state. We want to ensure,
171168 // however, that if we are currently trying to add a node, that we
172169 // have not expunged the zone of the keeper that we are trying to
@@ -247,18 +244,36 @@ impl ClickhouseAllocator {
247244 // Remove the keeper for the first expunged zone we see.
248245 // Remember, we only do one keeper membership change at time.
249246 new_config. keepers . remove ( zone_id) ;
247+
248+ if inventory_updated {
249+ // Save the log index from inventory because we are going to
250+ // need to use it to see if inventory has changed next time
251+ // through the planner.
252+ new_config. highest_seen_keeper_leader_committed_log_index =
253+ inventory_membership. leader_committed_log_index ;
254+ }
255+
250256 return bump_gen_if_necessary ( new_config) ;
251257 }
252258 }
253259
254- // Do we need to add any nodes to in service zones that don't have them
260+ // Do we need to add any nodes to in- service zones that don't have them
255261 for zone_id in & active_clickhouse_zones. keepers {
256262 if !new_config. keepers . contains_key ( zone_id) {
257263 // Allocate a new `KeeperId` and map it to the keeper zone
258264 new_config. max_used_keeper_id += 1 . into ( ) ;
259265 new_config
260266 . keepers
261267 . insert ( * zone_id, new_config. max_used_keeper_id ) ;
268+
269+ if inventory_updated {
270+ // Save the log index from inventory because we are going to
271+ // need to use it to see if inventory has changed next time
272+ // through the planner.
273+ new_config. highest_seen_keeper_leader_committed_log_index =
274+ inventory_membership. leader_committed_log_index ;
275+ }
276+
262277 return bump_gen_if_necessary ( new_config) ;
263278 }
264279 }
0 commit comments