Cluster bring-up can leave processes running when it is interrupted or the client cannot connect

未关闭
#1,064 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python

调研方向

Read the cluster bring-up paths in pybnf.main(), focusing on LocalCluster(...), the dask ssh client connection and readiness wait, and wait_for_srun_workers. Trace how each path handles KeyboardInterrupt and failures, then check the related LocalCluster.close(timeout=TEARDOWN_TIMEOUT) behavior. Done means interrupted or failed bring-up cleans up the processes and scheduler files described here, with the reported teardown timeout handled as well.

由索引模型根据 Issue 内容生成。

描述

bug low priority

Follow-up to #1063. That fix makes a local run close its LocalCluster at teardown, and also when local bring-up fails or is interrupted after LocalCluster(...) has returned. Its review found bring-up windows, on every cluster path, that still leave processes running. They are out of scope for #1063's PR, so they are collected here.

At a terminal the launchers share the process group and get the SIGINT themselves, so these mostly affect in-process use: a notebook, or the test suite calling pybnf.main(). In each case Cluster(...) never returns, so main() has no cluster to tear down.

1. Local: Ctrl-C while LocalCluster(...) is starting its workers

The #1063 guard (except BaseException) begins only after the constructor has returned and self._local_cluster is set. The constructor is nearly all of local bring-up. On a heavily loaded machine it measured 17.8 s, against 0.54 s for Client(lc) and 0.19 s for the init_logging broadcast. dask's own cleanup inside the constructor catches Exception only.

Reproduced with a real SIGINT during an in-process main(): "Fitting aborted.", exit 1, and 30 s later two workers were still alive with the LocalCluster still running. To make it deterministic, subclass LocalCluster and call signal.raise_signal(signal.SIGINT) at the end of __init__.

A candidate fix:

  • Hold SIGINT while the constructor runs. Then, if one arrived, raise KeyboardInterrupt inside the existing guarded block, so the normal close path runs.
  • This was prototyped and passed both reproductions. Its cost is that Ctrl-C is unresponsive for the length of worker start-up.
  • Closing the half-built instance from SpecCluster._instances does not work. Tried with a mid-start SIGINT, the cluster stuck at closing with both workers alive.
2. dask ssh: a failed client connection, or Ctrl-C during the readiness wait
  • Client(f'{scheduler_node}:8786') is outside any guard. If it raises, the dask ssh process PyBNF started keeps running.
  • wait_for_ssh_workers, which can take up to SSH_WORKER_TIMEOUT (120 s), is guarded by except Exception, so a Ctrl-C there leaves dask ssh running too.
3. srun: Ctrl-C during the readiness wait

wait_for_srun_workers is guarded by except Exception. A Ctrl-C there leaves the srun worker launcher(s), the scheduler and the scheduler file PyBNF wrote.

Items 2 and 3 behave the same on main as with the #1063 fix.

Related, in teardown

LocalCluster.close(timeout=TEARDOWN_TIMEOUT) raises TimeoutError on timeout and leaves the cluster closing with its workers alive. Cluster.stop_process kills a process that misses its timeout; nothing does that here. The error goes to the log file only ("Failed to tear down cluster"). This is unlikely at 30 s, since dask's nanny kills a worker about 4 s after asking it to stop. A run with SIGSTOPped workers and a 2 s timeout shows the behaviour.

主要语言
Python
星标
26
派生
25
平均合并
4 小时 25 分钟
30 天内合并 PR
9

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

lanl/PyBNF 的其他 Issue

查看 lanl/PyBNF 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。