lucasbru commented on PR #20127: URL: https://github.com/apache/kafka/pull/20127#issuecomment-3057467823
> It’s likely these tests pass because such a closed-loop scenario is rare. However, if that scenario does occur, the tests may fail, leading to flakiness. To avoid introducing flaky tests, it might be best to remove those that specifically check the impact of pairs. I think everything is deterministic in the unit tests. Where would the randomness come from? I ran the test 30k times to confirm, it never fails. > Additionally, it would be useful to understand why omitting pairs causes certain tests to fail for `LegacyStickyTaskAssignor`. My assumption is that it’s related to the task ID assignment order, which remains consistent in the legacy implementation but can change in the current approach. While this insight may not directly support the optimization, it is important for verifying the current implementation’s correctness. I checked, and I think the reason they pass is only partially due to task ID order. First, the unit tests in the new assignor will always pass, because it does order comparison instead of unordered comparison of assignments in the tests. So the unit tests related to "Not the same assignment" broke while being ported. Second, the old assignor does something weird: it assigns active tasks in sorted order, but standby tasks in reverse order. So in the common case, where we have "number of tasks = number of processes", this yields exactly the configuration we try to avoid: ``` {00000000-0000-0000-0000-000000000001=[activeTasks: ([0_0]) standbyTasks: ([0_3]) 00000000-0000-0000-0000-000000000002=[activeTasks: ([0_1]) standbyTasks: ([0_2]) 00000000-0000-0000-0000-000000000003=[activeTasks: ([0_2]) standbyTasks: ([0_1]) 00000000-0000-0000-0000-000000000004=[activeTasks: ([0_3]) standbyTasks: ([0_0]) ``` In the new algorithm (before optimizations), we use the order defined by `HashMaps`, and actually a somewhat complicated order based on the `Member` object which is inserted into a `HashSet`. That gives a deterministic, but somewhat random looking order, which will not create "pairs" in the test. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org