Skip to content

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

Closed

Activity

  1. added
    flaky test
    on May 20, 2022
  2. crusaderky commented on Jul 1, 2022

    @crusaderky
    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 🤷‍♂️

  3. fjetter commented on Jul 4, 2022

    @fjetter
    MemberAuthor

    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

  4. fjetter commented on Jul 4, 2022

    @fjetter
    MemberAuthor

    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

  5. crusaderky commented on Jul 4, 2022

    @crusaderky
    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)

  6. self-assigned this
    on Jul 4, 2022
  7. crusaderky commented on Jul 5, 2022

    @crusaderky
    Collaborator

    #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

Metadata

Metadata

Assignees

Labels

flaky test

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions