Skip to content

Reconnect times out waiting for workers #468

Closed

Description

Activity

  1. ncclementi commented on Nov 2, 2022

    @ncclementi
    Contributor

    @ntabris This one looks coiled rel;ated too, any thoughts?

     E               coiled.errors.ClusterCreationError: Only 9 workers ready (was waiting for at least 10).  (cluster_id: 98760)
    
    /usr/share/miniconda3/envs/test/lib/python3.9/site-packages/coiled/_beta/cluster.py:413:
    ClusterCreationError 
  2. ntabris commented on Nov 2, 2022

    @ntabris
    Member

    Sometimes you don't get all the instances you want. I don't consider this a problem unless it's happening with some frequency.

    In our docs, we say:

    You can also set wait_for_workers to True if you want to wait for all the requested workers. This option should be used with caution when requesting large clusters, due to availability issues from the chosen cloud provider.

    (https://docs.coiled.io/user_guide/cluster_creation.html#waiting-for-workers)

    Y'all make ~700 instances per CI run so I'm not surprised if sometimes some of those clusters don't get all the requested workers.

  3. ncclementi commented on Nov 4, 2022

    @ncclementi
    Contributor

    It is happening quite a bit, so I'll re-open.

  4. changed the title [-]⚠️ CI failed ⚠️[/-] [+]timeout waiting for workers[/+] on Nov 8, 2022
  5. self-assigned this
    on Nov 8, 2022
  6. ntabris commented on Nov 8, 2022

    @ntabris
    Member

    There are three recent examples:

    1. CI logs for 5641109480 - cluster details
    2. CI logs for 5657844011 - cluster details
    3. CI logs for 5644924689 - cluster details

    Problem 1: workers die during tests

    In each of these cases at least one of the workers dies. That's a dask problem, and maybe some on the OSS team should investigate why workers are losing connection to scheduler during test runs. For example, here's relevant bit of logs from one of the three (!) workers that did this on example (1) above:

    2022-11-04 12:21:51,484 - distributed.worker - INFO - Stopping worker at tls://10.0.3.171:43013. Reason: worker-handle-scheduler-connection-broken
    2022-11-04 12:21:51,490 - distributed.nanny - INFO - Closing Nanny gracefully at 'tls://10.0.3.171:34553'. Reason: worker-handle-scheduler-connection-broken
    2022-11-04 12:21:51,619 - distributed.nanny - INFO - Closing Nanny at 'tls://10.0.3.171:34553'. Reason: nanny-close-gracefully
    

    FWIW, I'd expect that benchmark code killing workings is considered a bad thing and something we'd want to track and something we'd want to look at for performance regressions.

    In all of these examples, Coiled does in fact bring up replacement instances (this is because the code running in CI calls scale for each test). But... that takes some time.

    That said, I'm looking at these clusters and the replacement workers come up in ~1 minute, so why are we getting 120s timeout?

    Problem 2: client.restart() is where we get timeout

    Why are we getting 120s timeout if the cluster.scale(10) gets us back to 10 workers in ~1 min?

    To answer that, we need to look more closely at the code where the timeout is coming from, and in each of the three examples I've been given, it's this same code:

       @pytest.fixture
        def small_client(
            request,
            testrun_uid,
            small_cluster,
            upload_cluster_dump,
            benchmark_all,
        ):
            test_label = f"{request.node.name}, session_id={testrun_uid}"
            with Client(small_cluster) as client:
                log_on_scheduler(client, "Starting client setup of %s", test_label)
    >           client.restart()
    
    conftest.py:486: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    /usr/share/miniconda3/envs/test/lib/python3.9/site-packages/distributed/client.py:3416: in restart
        return self.sync(
    /usr/share/miniconda3/envs/test/lib/python3.9/site-packages/distributed/utils.py:339: in sync
        return sync(
    /usr/share/miniconda3/envs/test/lib/python3.9/site-packages/distributed/utils.py:406: in sync
        raise exc.with_traceback(tb)
    /usr/share/miniconda3/envs/test/lib/python3.9/site-packages/distributed/utils.py:379: in f
        result = yield future
    /usr/share/miniconda3/envs/test/lib/python3.9/site-packages/tornado/gen.py:762: in run
        value = future.result()
    /usr/share/miniconda3/envs/test/lib/python3.9/site-packages/distributed/client.py:3385: in _restart
        await self.scheduler.restart(timeout=timeout, wait_for_workers=wait_for_workers)
    /usr/share/miniconda3/envs/test/lib/python3.9/site-packages/distributed/core.py:1154: in send_recv_from_rpc
        return await send_recv(comm=comm, op=key, **kwargs)
    /usr/share/miniconda3/envs/test/lib/python3.9/site-packages/distributed/core.py:944: in send_recv
        raise exc.with_traceback(tb)
    /opt/coiled/env/lib/python3.9/site-packages/distributed/core.py:770: in _handle_comm
        ???
    /opt/coiled/env/lib/python3.9/site-packages/distributed/utils.py:742: in wrapper
        ???
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    >   ???
    E   asyncio.exceptions.TimeoutError: Waited for 10 worker(s) to reconnect after restarting, but after 120s, only 9 have returned. Consider a longer timeout, or `wait_for_workers=False`.
    
    /opt/coiled/env/lib/python3.9/site-packages/distributed/scheduler.py:5804: TimeoutError

    Note that the code is calling client.restart() and then client.scale() but never gets to client.scale() in these cases because restart is where we get timeout!

    The default behavior of client.restart() is to wait for workers (ultimately by calling scheduler.restart(wait_for_workers=True).

    I'm a bit concerned that this won't work if the scheduler still thinks there are N workers but one of those workers has (unknown to the scheduler) died (because it lost connection to scheduler).

    Note that the small_client fixture used to do scale then wait_for_workers and then restart, change was made in 150f156 (cc @hendrikmakait who made that change).

    If you do things in that order, then I don't think you'd get timeout during restart call.

    Assessment/TODOs

    As far as I can tell, none of this is caused by Coiled platform issues.

    Workers die during tests, that should be addressed.

    client.restart() has timeout in some cases (I suspect when scheduler thinks worker is alive when it isn't), You could work around this by calling scale then wait then restart like you used to, but it feels to me like there's a problem with restart that should also be addressed.

    Also, I'll mention that troubleshooting would be easier if we had proper timestamps on things in runtime CI, as I've requested in #356.

    cc @jrbourbeau @fjetter for visibility on the dask issues

  7. removed their assignment
    on Nov 8, 2022
  8. ntabris commented on Nov 8, 2022

    @ntabris
    Member

    Just to be clear, the original example (from 19 days ago, not 4 days ago) is a different issue:

    coiled.errors.ClusterCreationError: Only 9 workers ready (was waiting for at least 10).  (cluster_id: 98760)
    

    If that's happening with increased frequency, it would require further investigation. I can do a quick check and see if I have access to data about how much that specific error is occurring.

  9. ntabris commented on Nov 8, 2022

    @ntabris
    Member

    Okay, so I looked specifically for cluster creation errors where we timed out waiting for requested number of workers.

    Here's last 30 days:

    image

    https://mixpanel.com/s/3xCCvY

    So... not increasing and not frequent.

    Most recent case was 104134 and we got Server.InternalError: Internal error on launch error from AWS.

    In general I'd expect this to be an AWS availability issue, but if it were to be more frequent we could try to tweak some things to get better availability.

  10. dchudz commented on Nov 8, 2022

    @dchudz
    Contributor

    Sounds like (as the error says) wait_for_workers=False on the restart would solve this?

    Then you'd get to the scale call, Coiled would get a chance to ask AWS for more workers for you.

  11. 10 remaining items

  12. self-assigned this
    on Nov 14, 2022
  13. ntabris commented on Nov 14, 2022

    @ntabris
    Member

    @ncclementi fyi this uncovered legitimate issues in upstream with @fjetter is currently working on addressing

  14. fjetter commented on Nov 15, 2022

    @fjetter
    Contributor

    I created an upstream ticket for this dask/distributed#7312

    Definitely looks like the worker is closed by a race condition during restart

  15. fjetter commented on Nov 15, 2022

    @fjetter
    Contributor

    Currently this looks like an issue because we're running restart while a previous restart has not completed, yet. Turns out the API we're calling on the Nanny to restart is not safe to be called concurrently, i.e. if we restart while a previous restart is still in progress, we're in a bad place.
    Looks like we're doing this in small_client https://github.com/coiled/coiled-runtime/blob/43c3fe7c69aff44802fde27f29b262bbda776c2b/conftest.py#L491-L510

    Once after a test finishes and once before a test starts. If we only do it once, we should be good. Does anybody know why we're calling it twice? Just for good measure or is there a reason? I see this was intentional but I don't have the full context #472

    cc @hendrikmakait


    Background is that even though Client|Scheduler.restart waits for the workers, the workers might still be finishing up their startup routine after they are registered to the scheduler so even Client.wait_for_workers will miss this race condition.

  16. hendrikmakait commented on Nov 15, 2022

    @hendrikmakait
    Contributor

    We have two calls to restart mostly for good measure. The one during teardown is needed to avoid problems/state spilling into subsequent tests using the same cluster. The one during setup is mostly to make sure that we do not have any stale state in the cluster since the fixture may be used without the small_client fixture and the user would then need to manually restart on teardown.

  17. hendrikmakait commented on Nov 15, 2022

    @hendrikmakait
    Contributor

    As an alternative approach with similar guarantees, we could create another function-level fixture to be used instead of small_cluster that restarts a cluster on teardown.

  18. fjetter commented on Nov 15, 2022

    @fjetter
    Contributor

    I'll push a hotfix for coiled-runtime until the distributed issue is fixed properly

  19. dchudz commented on Nov 15, 2022

    @dchudz
    Contributor

    Side note: I've always been a little nervous about cluster reuse across these tests.

    I understand it saves the cost of spinup time, so maybe that's worth it? But probably does make some things harder to disentangle.

    Although I guess it caught this bug, which is good.

  20. fjetter commented on Nov 15, 2022

    @fjetter
    Contributor

    Side note: I've always been a little nervous about cluster reuse across these tests.

    We're also not entirely happy with this. I believe package sync made it much faster but personally I still see a 1-2min startup time which is still pretty expensive compared to the test runtimes.

  21. ncclementi commented on Nov 16, 2022

    @ncclementi
    Contributor

    I see a lot of failures in multiple PRs and it looks like the fix proposed in #529 didn't do the trick.

    see https://github.com/coiled/coiled-runtime/actions/runs/3481356463/jobs/5822478047

    Edit: @ntabris I think I copy the wrong link, but isn't this kind of error the same/related?

    ERROR tests/benchmarks/test_futures.py::test_single_future - coiled.errors.ClusterCreationError: Only 1 workers ready (was waiting for at least 3).  (cluster_id: 112386)
    ERROR tests/benchmarks/test_futures.py::test_large_map - coiled.errors.ClusterCreationError: Only 1 workers ready (was waiting for at least 3).  (cluster_id: 112386)
    ERROR tests/benchmarks/test_futures.py::test_large_map_first_work - coiled.errors.ClusterCreationError: Only 1 workers ready (was waiting for at least 3).  (cluster_id: 112386)
    ERROR tests/benchmarks/test_futures.py::test_memory_efficient - coiled.errors.ClusterCreationError: Only 1 workers ready (was waiting for at least 3).  (cluster_id: 112386)
    

    Or this could be related to the insufficient instance types. If I'm in the wrong, happy to close this and open a new issue.

  22. ntabris commented on Nov 16, 2022

    @ntabris
    Member

    that's a different error, let's look more closely

  23. fjetter commented on Nov 16, 2022

    @fjetter
    Contributor

    I'll close this again to avoid mixing this up. I suggest opening a new ticket for the cluster creation error if that hasn't happened already

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

cause: upstream (dask)ci-failurestability

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions