apache / helix

Mirror of Apache Helix
Apache License 2.0
461 stars 224 forks source link

[apache/helix] -- Fix PreferenceList Ordering Changes during Maintenance Mode #2778

Closed himanshukandwal closed 5 months ago

himanshukandwal commented 5 months ago

Issues

Description

Tests

Added Tests: TestMaintenanceRebalancer.testComputeIdealState This covers various scenarios where the preference list should be preserved wrt current state

mvn clean install -Dmaven.test.skip.exec=true && mvn test -o -Dtest=TestMaintenanceRebalancer -pl=helix-core

[INFO] --- surefire:3.0.0-M3:test (default-test) @ helix-core ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.apache.helix.controller.rebalancer.TestMaintenanceRebalancer
Test case comment: [Case 1] Same state - No (A, B, C) -> (A, C, B) for different hash order
[lKmBBEPisM, 8PNpMU7EgT, HOs3rOFCad]
[lKmBBEPisM, 8PNpMU7EgT, HOs3rOFCad]
Test case comment: [Case 2] Same state - No (A, B, C) -> (A, C, B) for different hash order
[Q3ZZuCeBpu, QY9U91XBYo, GMYBW20gmC]
[Q3ZZuCeBpu, QY9U91XBYo, GMYBW20gmC]
Test case comment: [Case 3] second becomes leader, (A, B, C) -> (B, A, C) for different hash order
[8PNpMU7EgT, lKmBBEPisM, HOs3rOFCad]
[8PNpMU7EgT, lKmBBEPisM, HOs3rOFCad]
Test case comment: [Case 4] second becomes leader, (A, B, C) -> (B, A, C) for different hash order
[QY9U91XBYo, Q3ZZuCeBpu, GMYBW20gmC]
[QY9U91XBYo, Q3ZZuCeBpu, GMYBW20gmC]
Test case comment: [Case 5] leader becomes offline, (A, B, C) -> (B, C, A) for different hash order
[8PNpMU7EgT, HOs3rOFCad, lKmBBEPisM]
[8PNpMU7EgT, HOs3rOFCad, lKmBBEPisM]
Test case comment: [Case 6] leader becomes offline, (A, B, C) -> (B, C, A) for different hash order
[QY9U91XBYo, GMYBW20gmC, Q3ZZuCeBpu]
[QY9U91XBYo, GMYBW20gmC, Q3ZZuCeBpu]
[INFO] Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.983 s - in org.apache.helix.controller.rebalancer.TestMaintenanceRebalancer
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 6, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] 
[INFO] --- jacoco:0.8.6:report (generate-code-coverage-report) @ helix-core ---
[INFO] Loading execution data file /Users/hkandwal/Documents/workspaces/projects/helix_os_hk/helix-core/target/jacoco.exec
[INFO] Analyzed bundle 'Apache Helix :: Core' with 950 classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  42.293 s
[INFO] Finished at: 2024-03-14T11:50:53-07:00
[INFO] ------------------------------------------------------------------------

Changes that Break Backward Compatibility (Optional)

(Consider including all behavior changes for public methods or API. Also include these changes in merge description so that other developers are aware of these changes. This allows them to make relevant code changes in feature branches accounting for the new method/API behavior.)

Documentation (Optional)

(Link the GitHub wiki you added)

Commits

Code Quality

himanshukandwal commented 5 months ago

Successful CI Build: https://github.com/himanshukandwal/helix/actions/runs/8286133854

himanshukandwal commented 5 months ago

You should update the description or add comments:

  1. We first sort on Preference List (does it have any special comparator?)
  2. We sort on StateModelDef

it would be useful to add comments.

Yes, updated the code with comments. Thanks Komal!

himanshukandwal commented 5 months ago

This change has been reviewed and approved by @zpinto and @desaikomal

Final Commit Message: Fixed PreferenceList Ordering Changes (indeterminism) during Maintenance Mode.