Repository navigation
🐛 Director-v2: a closing dask client is not a scheduler change - #10308
Merged
mergify[bot] merged 1 commit intoDec 3, 2026
Conversation
`check_scheduler_is_still_the_same` reported a `scheduler_info()` without an `id` as a replaced dask scheduler. That cache is emptied by `distributed.Client._close`, and director-v2 connects with `asynchronous=True`, so `scheduler_info()` returns only the cache: a client that starts closing reports a scheduler change. That error is terminal in the computational scheduler - it marks every processing task FAILED. director-v2 closes its dask clients in the dask-clients-pool lifespan on shutdown, while a scheduling iteration may still be running, so a rolling update declared a run lost whose dask-scheduler was alive and untouched. An empty cache now goes through `check_scheduler_status`, so a client that is not running raises `ComputationalBackendNotConnectedError`, which the scheduler already treats as transient: tasks wait in WAITING_FOR_CLUSTER and resume when a replica reconnects. `ComputationalSchedulerChangedError` now requires evidence of a different scheduler id. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
sanderegg
force-pushed
the
fix/director-v2-closing-dask-client-not-scheduler-change
branch
from
December 3, 2026 11:33
336ee62 to
945e961
Compare
|
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the change distinguishing Dask client shutdown from scheduler replacement.
No open issues 🎉
What changed in this PR
Prevents director-v2 shutdown from incorrectly failing running computational jobs by distinguishing a closing Dask client from a replaced scheduler.
Changes:
- Checks client status before treating a missing scheduler ID as a scheduler change.
- Adds regression tests for closed-client error handling and task recovery without resubmission or resource release.
| File | Description |
|---|---|
services/director-v2/src/simcore_service_director_v2/utils/dask.py |
Treats non-running clients with missing scheduler IDs as transient disconnects. |
services/director-v2/tests/unit/test_modules_dask_client.py |
Tests closed-client handling while the scheduler remains alive. |
services/director-v2/tests/unit/with_dbs/comp_scheduler/test_scheduler_dask.py |
Tests waiting and recovery without resubmitting tasks or releasing resources. |
Review effort: Balanced
sanderegg
marked this pull request as ready for review
December 3, 2026 13:07
sanderegg
requested review from
Konohana0608,
giancarloromeo,
matusdrobuliak66 and
wvangeit
December 3, 2026 13:08
giancarloromeo
approved these changes
Dec 3, 2026
wvangeit
approved these changes
Dec 3, 2026
pcrespov
approved these changes
Dec 3, 2026
Contributor
✅ Merged into
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Goal
Stop director-v2 from failing running computational jobs when it shuts down.
What do these changes do?
distributed.Client._closeclears the client's scheduler-identity cache, and director-v2 connects withasynchronous=True, soscheduler_info()returns only that cache. A client that has started closing reports no scheduler id, whichcheck_scheduler_is_still_the_sameread as a replaced scheduler. That error is terminal: the computational scheduler marks every processing task FAILED. director-v2 closes its dask clients on shutdown, while a scheduling iteration can still be running, so a rolling update declared a live run lost.An empty cache now goes through
check_scheduler_statusfirst, so a client that is not running raisesComputationalBackendNotConnectedError. The scheduler already treats that error as transient - tasks wait inWAITING_FOR_CLUSTER, bounded byCOMPUTATIONAL_BACKEND_MAX_WAITING_FOR_CLUSTER_TIMEOUT, and resume when a replica reconnects - so it needed no change.ComputationalSchedulerChangedErrornow fires only on a differing scheduler id and stays terminal.Two tests. Closing the director-v2 dask client against a live
SpecClustermust raise the transient error, and a second client still reports the same scheduler id. An unreachable backend must leave tasks inWAITING_FOR_CLUSTER, keep the run unreleased and unscheduled, and return the tasks toSTARTEDonce the backend answers.Follow-up
Shutting down still does not drain scheduling iterations that are already running, so clients that close later in the lifespan (database, storage) can still be reached mid-iteration. Tracked under #4524.
Related issue/s
How to test
The second target needs the core and ops swarm stack for postgres and rabbitmq, so it is slower. It did not run locally; CI's
[unit] director-v2job ran both tests and they passed:pytest tests/unit/with_dbs/comp_scheduler/test_scheduler_dask.py -k "backend_client_being_closed or scheduler_changes or scheduler_offline" -vDev-ops
No changes, no new environment variables.
AI assistance
Assisted-by: GitHub Copilot VS Code agent (Copilot SDK) [bash] [pytest] [ruff]