Skip to content

Return all workers from scheduler_info() by default#9308

Merged
mrocklin merged 3 commits into
dask:mainfrom
mrocklin:claude/cranky-shirley-0445ad
Jul 3, 2026
Merged

Return all workers from scheduler_info() by default#9308
mrocklin merged 3 commits into
dask:mainfrom
mrocklin:claude/cranky-shirley-0445ad

Conversation

@mrocklin

Copy link
Copy Markdown
Member

Client.scheduler_info() defaulted to n_workers=5, silently truncating the "workers" dict to the first five workers. This was misleading and, more importantly, broke restart_workers: both the nanny-required validation and the worker name -> address resolution read this truncated set, so on clusters with more than five workers the nanny check was silently skipped and name-based restarts of later workers misfired.

Changes:

  • scheduler_info() now defaults to n_workers=-1 (all workers). This only affects explicit, on-demand calls, not the periodic per-client poll, so the scheduler-scalability fix from Reduce size of scheduler_info #9045 / Scheduler not robust to many connected clients #9043 is not reintroduced (the periodic cache populator stays capped at 5).
  • _restart_workers now fetches a fresh, full identity via scheduler.identity(n_workers=-1) and performs both the nanny check and the name resolution there, correct for any cluster size. This also collapses the previous two identity RPCs on the sync path into one.

Adds a regression test that restarts a non-nanny worker beyond the historical five-worker cap; it raises the expected error only with the fix.

xref #9065

`Client.scheduler_info()` defaulted to `n_workers=5`, silently truncating
the "workers" dict to the first five workers. This was misleading and, more
importantly, broke `restart_workers`: both the nanny-required validation and
the worker name -> address resolution read this truncated set, so on clusters
with more than five workers the nanny check was silently skipped and
name-based restarts of later workers misfired.

Changes:
- `scheduler_info()` now defaults to `n_workers=-1` (all workers). This only
  affects explicit, on-demand calls, not the periodic per-client poll, so the
  scheduler-scalability fix from dask#9045 / dask#9043 is not reintroduced (the
  periodic cache populator stays capped at 5).
- `_restart_workers` now fetches a fresh, full identity via
  `scheduler.identity(n_workers=-1)` and performs both the nanny check and the
  name resolution there, correct for any cluster size. This also collapses the
  previous two identity RPCs on the sync path into one.
- Document the sync/async asymmetry: async clients read the periodically
  cached value, so `n_workers` is only honored for synchronous clients.

Adds a regression test that restarts a non-nanny worker beyond the historical
five-worker cap; it raises the expected error only with the fix.

xref dask#9065

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mrocklin mrocklin requested a review from fjetter as a code owner June 26, 2026 21:49
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

    40 files  ± 0      40 suites  ±0   14h 57m 16s ⏱️ + 10m 49s
 4 158 tests + 2   3 978 ✅ + 1    178 💤 ±0  2 ❌ +1 
80 918 runs  +37  76 682 ✅ +38  4 234 💤  - 2  2 ❌ +1 

For more details on these failures, see this check.

Results for commit 8dbd811. ± Comparison against base commit 9e706be.

♻️ This comment has been updated with latest results.

@mrocklin

Copy link
Copy Markdown
Member Author

Merging monday if there are no further comments.

Comment thread distributed/client.py
Comment on lines 4512 to 4514
if not self.asynchronous:
self.sync(self._update_scheduler_info, n_workers=n_workers)
return self._scheduler_identity

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

scheduler_info() still returns 5 workers for async clients.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Valid point. Fixed. We now don't get any workers on the periodic updates so that the non-active querying of historical state is less wrong. It can still be stale, but it won't be consistently stale in an obvious way any longer.

Comment thread distributed/client.py
Comment on lines +3919 to +3922
# Fetch info for all workers (not the truncated cache from
# ``scheduler_info``) so that name resolution and the nanny check below
# are correct on clusters with many workers.
workers_info = (await self.scheduler.identity(n_workers=-1))["workers"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Isn't it cleaner to just call self._get_scheduler_info()?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think that this is difficult because we're in an async block and _get_scheduler_info() calls sync.

@crusaderky crusaderky mentioned this pull request Jul 3, 2026
4 tasks
crusaderky and others added 2 commits July 3, 2026 16:33
Following review feedback: `scheduler_info()` previously returned up to 5
workers for asynchronous clients, since they read the periodically refreshed
`_scheduler_identity` cache rather than fetching on demand (a sync method
can't await inside the event loop). Returning an arbitrary five workers is
misleading.

The cached identity exists only to feed the client repr, which needs the
cluster-wide totals (`n_workers`, `total_threads`, `total_memory`) — and those
are maintained as scheduler-level aggregates, independent of the worker dict.
So the periodic `_update_scheduler_info` now fetches `n_workers=0`: totals are
still accurate, and `scheduler_info()["workers"]` is empty for async clients
rather than a misleading subset. Synchronous clients are unaffected (they
refetch with all workers by default). This also shrinks the periodic payload
further, reinforcing the scheduler-scalability fix from dask#9045.

Callers that need per-worker detail on an async client fetch it explicitly via
`await client.scheduler.identity(n_workers=-1)`; async tests that relied on the
cached workers are updated accordingly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mrocklin mrocklin merged commit edf6778 into dask:main Jul 3, 2026
48 of 51 checks passed
@mrocklin mrocklin deleted the claude/cranky-shirley-0445ad branch July 3, 2026 19:37
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