Skip to content

Fix flaky test_no_reconnect[--no-nanny] - #5686

Merged
jcrist merged 4 commits into
dask:mainfrom
graingert:fix-flakey-test-no-reconnect-no-nanny
Jan 27, 2022
Merged

jcrist merged 4 commits into
dask:mainfrom
graingert:fix-flakey-test-no-reconnect-no-nanny

Conversation

@graingert

@graingert graingert commented Jan 24, 2022 •

Copy link
Copy Markdown
Member

when investigating this flakey test on tmux I found that distributed.utils_test.wait_for_port was consuming 100% cpu in a tight loop around socket.create_connection, delaying the startup of the worker process longer than 5 seconds. I worked around this by running the Scheduler in the test directly.

this PR also restores the original purpose of the test:

test_no_reconnect was originally added here:
2c2a33f#diff-f23384aa58b61650a9a8b7986f731bc77294f89c9e65187fbfea0dace6692008R44-R51

the purpose of the test appears to be to see if once the connection to the scheduler is interrupted the worker process should terminate on its own, however in d1edbac#diff-f23384aa58b61650a9a8b7986f731bc77294f89c9e65187fbfea0dace6692008R51 when the worker and scheduler context managers were swapped, however the while is_alive(worker) check was moved outside the popen(['dask-worker', ... context manager which terminates the process anyway.

@GPUtester

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@graingert graingert changed the title Fix flakey Fix flakey test_no_reconnect[--no-nanny] (dask#5680) Jan 24, 2022
@graingert graingert changed the title Fix flakey test_no_reconnect[--no-nanny] (dask#5680) Fix flakey test_no_reconnect[--no-nanny] Jan 24, 2022

@fjetter fjetter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice catch!

@crusaderky crusaderky changed the title Fix flakey test_no_reconnect[--no-nanny] Fix flaky test_no_reconnect[--no-nanny] Jan 24, 2022
@crusaderky crusaderky added the flaky test Intermittent failures on CI. label Jan 24, 2022
@fjetter

fjetter commented Jan 25, 2022

Copy link
Copy Markdown
Member

@graingert is there anything you wanted to add here? If not we're good to merge

Comment thread distributed/utils_test.py
print(out.decode())


def wait_for_port(address, timeout=5):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have no idea if anybody is using this but imho this should not be part of our public API

@graingert
graingert marked this pull request as ready for review January 25, 2022 12:16
@graingert

Copy link
Copy Markdown
Member Author

@graingert is there anything you wanted to add here? If not we're good to merge

there's nothing else other than what we want to do with wait_for_port

@jcrist jcrist left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks for the fix!

from asyncio import to_thread
else:

async def to_thread(*func_args, **kwargs):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I could see this being useful elsewhere, and it feels a bit odd to inline it in the test file. Perhaps move it to distributed.utils instead?

there's a chance wait_for_workers will return before the worker
notices the connection was aborted
@graingert
graingert force-pushed the fix-flakey-test-no-reconnect-no-nanny branch from efd1142 to 5b7597c Compare January 27, 2022 13:20
@graingert
graingert force-pushed the fix-flakey-test-no-reconnect-no-nanny branch from 5b7597c to bc8d31c Compare January 27, 2022 13:32
@jcrist

jcrist commented Jan 27, 2022

Copy link
Copy Markdown
Member

The macos tests seem slow lately on GHA. Since this passed before, going to skip them and merge as is. Thanks @graingert!

@jcrist
jcrist merged commit dbc5b0f into dask:main Jan 27, 2022
gjoseph92 pushed a commit to gjoseph92/distributed that referenced this pull request Feb 1, 2022
* Fix flakey `test_no_reconnect[--no-nanny]` (dask#5680)

* remove unused `wait_for_port`

* avoid wait_for_workers in test_reconnect

there's a chance wait_for_workers will return before the worker
notices the connection was aborted

* make `utils_test.terminate_process` private
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flaky test Intermittent failures on CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flaky test_no_reconnect[--no-nanny] TimeoutError: Operation timed out after None seconds

5 participants