Re-enable cluster state transition optimization
Made side effects of replica resurrection bug more likely to be observed,
but not in itself a believed root cause of any issues.
@@ -128,7 +128,7 @@ BucketDBUpdater::recheckBucketInfo(uint32_t nodeIdx,
void
BucketDBUpdater::removeSuperfluousBuckets(
const lib::ClusterStateBundle& newState,
- [[maybe_unused]] bool is_distribution_config_change)
+ bool is_distribution_config_change)
{
const bool move_to_read_only_db = shouldDeferStateEnabling();
const char* up_states = _distributorComponent.getDistributor().getStorageNodeUpStates();
@@ -137,6 +137,16 @@ BucketDBUpdater::removeSuperfluousBuckets(
const auto& oldClusterState(elem.second->getClusterState());
const auto& new_cluster_state = newState.getDerivedClusterState(elem.first);
+ // Running a full DB sweep is expensive, so if the cluster state transition does
+ // not actually indicate that buckets should possibly be removed, we elide it entirely.
+ if (!is_distribution_config_change
+ && db_pruning_may_be_elided(oldClusterState, *new_cluster_state, up_states))
+ {
+ LOG(debug, "Eliding DB pruning for state transition '%s' -> '%s'",
+ oldClusterState.toString().c_str(), new_cluster_state->toString().c_str());
+ continue;
+ }
+
auto& bucketDb(elem.second->getBucketDatabase());
auto& readOnlyDb(_distributorComponent.getReadOnlyBucketSpaceRepo().get(elem.first).getBucketDatabase());
