Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

distributed/tests/test_asyncprocess.py::test_signal flaky #6393

Closed
fjetter opened this issue May 20, 2022 · 5 comments · Fixed by #6671
Closed

distributed/tests/test_asyncprocess.py::test_signal flaky #6393

fjetter opened this issue May 20, 2022 · 5 comments · Fixed by #6671
Assignees
Labels
flaky test Intermittent failures on CI.

Comments

@fjetter
Copy link
Member

fjetter commented May 20, 2022

https://github.com/dask/distributed/runs/6513746712?check_suite_focus=true

as part of #6381

running into an async test timeout

@fjetter fjetter added the flaky test Intermittent failures on CI. label May 20, 2022
@crusaderky
Copy link
Collaborator

I'm getting a new error:
https://github.com/dask/distributed/pull/6633/checks?check_run_id=7150089143

>       assert proc.exitcode in (-signal.SIGTERM, 255)
E       assert -9 in (-15, 255)
E        +  where -9 = <AsyncProcess SpawnProcess-220>.exitcode

I cannot understand how the process received SIGKILL after we sent SIGTERM 🤷‍♂️

@fjetter
Copy link
Member Author

fjetter commented Jul 4, 2022

There are a couple of places we are issuing a SIGKILL

  • Worker memory_monitor
  • A couple of error handlers in nanny
    logger.exception("Nanny failed to start process", exc_info=True)
    self.process.terminate()
    self.status = Status.failed
    return self.status
    try:
    msg = await self._wait_until_connected(uid)
    except Exception:
    logger.exception("Failed to connect to process")
    self.status = Status.failed
    self.process.terminate()
  • Lastly, while shutting down the nanny, if the worker process didn't close in time
    await process.terminate()

The last item on this list reminds me of #6493 (comment) where I was also finding a worker not closing as expected

@fjetter
Copy link
Member Author

fjetter commented Jul 4, 2022

Turns out, the AsyncProcess also has a finalizer that is terminating the process. I do not see any logs in the failing CI, though

def _asyncprocess_finalizer(proc):
if proc.is_alive():
try:
logger.info(f"reaping stray process {proc}")
proc.terminate()
except OSError:
pass

@crusaderky
Copy link
Collaborator

Worker memory_monitor

The nanny isn't involved in this test though

All those calls to terminate() sends SIGTERM, not SIGKILL:

def terminate(self) -> asyncio.Future[None]:
"""Terminate the child process.
This method returns a future.
See also
--------
multiprocessing.Process.terminate
"""
self._check_closed()
fut: Future[None] = Future()
self._watch_q.put_nowait({"op": "terminate", "future": fut})
return fut
def kill(self) -> asyncio.Future[None]:
"""Send SIGKILL to the child process.
On Windows, this is the same as terminate().
This method returns a future.
See also
--------
multiprocessing.Process.kill
"""
self._check_closed()
fut: Future[None] = Future()
self._watch_q.put_nowait({"op": "kill", "future": fut})
return fut

elif op == "terminate":
# Send SIGTERM
_call_and_set_future(loop, msg["future"], process.terminate)
elif op == "kill":
# Send SIGKILL
_call_and_set_future(loop, msg["future"], process.kill)

@crusaderky
Copy link
Collaborator

crusaderky commented Jul 5, 2022

#6671 xfails the tests on MacOSX when the test expects SIGINT or SIGTERM as a return code but it gets SIGKILL instead.
Should we keep this issue open for a future fix? I am personally disinclined to spend more time on it, as this hardly affects the tested software. Any third-party nanny that tests our exit codes should only ever check zero vs. nonzero.

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 a pull request may close this issue.

2 participants