Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a single setting to enable/disable primary shard balance/rebalance #17362

Open
bugmakerrrrrr opened this issue Feb 14, 2025 · 0 comments
Open
Labels
enhancement Enhancement or improvement to existing feature or request ShardManagement:Placement untriaged

Comments

@bugmakerrrrrr
Copy link
Contributor

Is your feature request related to a problem? Please describe

Today, we use settings cluster.routing.allocation.balance.prefer_primary and cluster.routing.allocation.rebalance.primary.enable to enable/disable primary shard balance and rebalance separately.

private void setPreferPrimaryShardBalance(boolean preferPrimaryShardBalance) {
this.preferPrimaryShardBalance = preferPrimaryShardBalance;
this.weightFunction.updateAllocationConstraint(INDEX_PRIMARY_SHARD_BALANCE_CONSTRAINT_ID, preferPrimaryShardBalance);
this.weightFunction.updateAllocationConstraint(CLUSTER_PRIMARY_SHARD_BALANCE_CONSTRAINT_ID, preferPrimaryShardBalance);
this.weightFunction.updateRebalanceConstraint(INDEX_PRIMARY_SHARD_BALANCE_CONSTRAINT_ID, preferPrimaryShardBalance);
}
private void setPreferPrimaryShardRebalance(boolean preferPrimaryShardRebalance) {
this.preferPrimaryShardRebalance = preferPrimaryShardRebalance;
this.weightFunction.updateRebalanceConstraint(CLUSTER_PRIMARY_SHARD_REBALANCE_CONSTRAINT_ID, preferPrimaryShardRebalance);
}

But it is wired that we also enable the constraint INDEX_PRIMARY_SHARD_BALANCE_CONSTRAINT_ID in RebalanceConstraints when settings cluster.routing.allocation.balance.prefer_primary as true, by definition, it should be controlled by the rebalance configuration.

On the other hand, just turning on AllocationConstraints doesn't do much good, as it may still cause the primary shards to become unbalanced during rebalance.

Describe the solution you'd like

Use a single setting cluster.routing.allocation.balance.prefer_primary to control primary shard balance and rebalance, deprecate the setting cluster.routing.allocation.rebalance.primary.enable and remove it in OS 3.0.

Related component

ShardManagement:Placement

Describe alternatives you've considered

No response

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement or improvement to existing feature or request ShardManagement:Placement untriaged
Projects
Status: 🆕 New
Development

No branches or pull requests

1 participant