Return all workers from scheduler_info() by default#9308
Conversation
`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>
Unit Test ResultsSee 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 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. |
|
Merging monday if there are no further comments. |
| if not self.asynchronous: | ||
| self.sync(self._update_scheduler_info, n_workers=n_workers) | ||
| return self._scheduler_identity |
There was a problem hiding this comment.
scheduler_info() still returns 5 workers for async clients.
There was a problem hiding this comment.
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.
| # 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"] |
There was a problem hiding this comment.
Isn't it cleaner to just call self._get_scheduler_info()?
There was a problem hiding this comment.
I think that this is difficult because we're in an async block and _get_scheduler_info() calls sync.
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>
Client.scheduler_info()defaulted ton_workers=5, silently truncating the "workers" dict to the first five workers. This was misleading and, more importantly, brokerestart_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 ton_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_workersnow fetches a fresh, full identity viascheduler.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