Fix PreferenceList Ordering Changes during Maintenance Mode
himanshukandwal opened this issue · 0 comments
Describe the bug
When entering maintenance-mode, we observed that instance order in preference list changes by PreferenceListNodeComparator as it uses the order in which the current-state is materialized in array list.
For instance:
Lets say we have 3 hosts, and here's the Current state:
{
A: LEADER,
B: FOLLOWER
C: FOLLOWER
}
Now when we create a preference-list using new ArrayList(currentState.keySet), the order in array-list depends on the hash order the keys (A, B, C). With sorting using PreferenceListNodeComparator, we put Leader at the front and ordering among Followers can be anything and could either be [A, B, C] or [A, C, B ]
To Reproduce
If we have a set of string where the hash order is different than the insert order then we can see this issue:
Insert order: [Q3ZZuCeBpu, QY9U91XBYo, GMYBW20gmC]
Hash set order: [GMYBW20gmC, QY9U91XBYo, Q3ZZuCeBpu]
Expected behavior
The preference list order should not change as computed earlier.
Additional context
Add any other context about the problem here.