@@ -147,17 +147,8 @@ impl ClickhouseAllocator {
147
147
return bump_gen_if_necessary ( new_config) ;
148
148
} ;
149
149
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 ;
161
152
162
153
if current_keepers != inventory_membership. raft_config {
163
154
// We know that there is a reconfiguration in progress. If there has
@@ -167,6 +158,12 @@ impl ClickhouseAllocator {
167
158
return bump_gen_if_necessary ( new_config) ;
168
159
}
169
160
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
+
170
167
// We're still trying to reach our desired state. We want to ensure,
171
168
// however, that if we are currently trying to add a node, that we
172
169
// have not expunged the zone of the keeper that we are trying to
@@ -247,18 +244,36 @@ impl ClickhouseAllocator {
247
244
// Remove the keeper for the first expunged zone we see.
248
245
// Remember, we only do one keeper membership change at time.
249
246
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
+
250
256
return bump_gen_if_necessary ( new_config) ;
251
257
}
252
258
}
253
259
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
255
261
for zone_id in & active_clickhouse_zones. keepers {
256
262
if !new_config. keepers . contains_key ( zone_id) {
257
263
// Allocate a new `KeeperId` and map it to the keeper zone
258
264
new_config. max_used_keeper_id += 1 . into ( ) ;
259
265
new_config
260
266
. keepers
261
267
. 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
+
262
277
return bump_gen_if_necessary ( new_config) ;
263
278
}
264
279
}
0 commit comments