Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@dkropachev
Copy link
Collaborator

@dkropachev dkropachev commented Nov 4, 2025

In cases when nodes are listed not in a proper groups of dc (for DCAwareRoundRobinPolicy) and dc+rack (for RackAwareRoundRobinPolicy).
Policy register only nodes from the last group or dc+rack. So, policy knows only last group of nodes, rest of the nodes considered to be non-existent, until node is restarted, which can be days.

Fixes: #576

Pre-review checklist

  • I have split my patch into logically separate commits.
  • All commit messages clearly explain what they change and why.
  • I added relevant tests for new features and bug fixes.
  • All commits compile, pass static checks and pass test.
  • PR description sums up the changes and reasons why they should be introduced.
  • I have provided docstrings for the public items that I want to introduce.
  • I have adjusted the documentation in ./docs/source/.
  • I added appropriate Fixes: annotations to PR description.

In cases when nodes are listed not in a proper groups of dc (for DCAwareRoundRobinPolicy) and dc+rack (for RackAwareRoundRobinPolicy).
Policy register only nodes from the last group or dc+rack.
So, policy knows only last group of nodes, rest of the nodes considered
to be non-existent, until node is restarted, which can be days.
@dkropachev dkropachev marked this pull request as ready for review November 4, 2025 09:13
Comment on lines 255 to 257
for dc, dc_hosts in groupby(hosts, lambda h: self._dc(h)):
self._dc_live_hosts[dc] = tuple(set(dc_hosts))
self._dc_live_hosts[dc] = tuple({*dc_hosts, *self._dc_live_hosts.get(dc, [])})

Choose a reason for hiding this comment

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

Personally I think such comprehensions / unpacking (or w/e is this called) is much less readable than something simpler like

for dc, dc_hosts in groupby(hosts, lambda h: self._dc(h)):
    self._dc_live_hosts.setdefault(dc, set())
    self._dc_live_hosts[dc].update(dc_hosts)

I'd prefer it to be changed, but I won't hold this PR over that.

Choose a reason for hiding this comment

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

Btw if we are staying with the current version, let's change .get(dc, []) to .get(dc,set()).
It won't change how the code works but makes it imo easier to reason about - _dc_live_hosts is a dict str -> set of hosts, so let's keep it that way.

@dkropachev dkropachev merged commit b3c63c0 into scylladb:master Nov 4, 2025
16 of 17 checks passed
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.

DCAwareRoundRobinPolicy and RackAwareRoundRobinPolicy populate does no register all the nodes in some cases

3 participants