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

Fix primary shard balance parameter #17352

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bugmakerrrrrr
Copy link
Contributor

Description

Serval changes here:

  • fix settings preferPrimaryShardBalance/Rebalance be reset when updating other settings due to a new WeightFunction object is created without inherit original Constraint parameters

private void updatePreferPrimaryShardBalanceBuffer(float preferPrimaryShardBalanceBuffer) {
this.preferPrimaryShardRebalanceBuffer = preferPrimaryShardBalanceBuffer;
updateWeightFunction();
}
private void updateWeightFunction() {
weightFunction = new WeightFunction(
this.indexBalanceFactor,
this.shardBalanceFactor,
this.preferPrimaryShardRebalanceBuffer,
this.primaryConstraintThreshold
);
}

  • separate preferPrimaryShardBalance/preferPrimaryShardRebalance updating;
  • refactor some code

Related Issues

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link
Contributor

❌ Gradle check result for ba0ea2b: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@@ -40,6 +40,10 @@ public void setEnable(boolean enable) {
this.enable = enable;
}

public boolean isEnable() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: isEnabled

@bugmakerrrrrr
Copy link
Contributor Author

bugmakerrrrrr commented Feb 13, 2025

❌ Gradle check result for ba0ea2b: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

This test fails because a node is removed after a cluster is init, resulting in rebalancing, and the original setting of preferPrimaryShardBalance also enabled the INDEX_PRIMARY_SHARD_BALANCE_CONSTRAINT_ID constraint in RebalanceConstraints, looks like we need to keep the original behavior, or we can use one setting preferPrimaryShardBalance to enable all constraints.

}

/**
* When primary shards balance is desired, enable primary shard balancing constraints
* @param preferPrimaryShardBalance boolean to prefer balancing by primary shard
*/
private void setPreferPrimaryShardBalance(boolean preferPrimaryShardBalance) {
void setPreferPrimaryShardBalance(boolean preferPrimaryShardBalance) {
this.preferPrimaryShardBalance = preferPrimaryShardBalance;
this.weightFunction.updateAllocationConstraint(INDEX_PRIMARY_SHARD_BALANCE_CONSTRAINT_ID, preferPrimaryShardBalance);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another concern, do we need to ensure that we update all the constraints in AllocationConstraints or RebalanceConstraints at the same time to avoid having only some of the constraints enabled during allocation or rebalance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants