loom participant retire cannot retire an orphaned participant after container replacement or host reboot

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

维护者通常 1 天内回复

@l0K1ngg 已经在做这个了。

开始于 2026年12月2日。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
clickhouse, docker, kubernetes, python
领域
backend, cli, databases

调研方向

Start with server/cli/participant.py and trace retire_participant() through _retire_dead_row() to proves_stopped() in server/core/provider_process.py; read the authority and running-query checks in server/insights/app/provider_barrier.py too. Reproduce the orphaned participant case described in the issue, then determine how retirement can safely support verified dead processes after container replacement or reboot. Done means the documented CLI recovery succeeds while settled-query checks remain enforced.

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

描述

bug help wanted up-for-grabs
Company

Independent

Component

CLI

Describe what's wrong

When a Loom process exits without recording state = 'retired' in loom._provider_participants and its container/Pod is replaced (or the host reboots), /v1/health surfaces provider_participants_stale with the recovery instruction:

Fix: On its trusted host, verify exact physical death and settled queries with `loom participant retire --participant <id>`. Expiry or a deleted pod object does not prove death.

However, loom participant retire --participant <id> (server/cli/participant.py -> retire_participant() -> _retire_dead_row() -> proves_stopped() in server/core/provider_process.py) requires all three of:

if host != socket.gethostname() or boot != my_boot:
    return False
if pidns != my_pidns:
    return False

This creates an unrecoverable dead-end in standard deployments whenever the original runtime context no longer exists:

  1. Docker Compose (compose.yaml, including COMPOSE_PROFILES=bundled) & Kubernetes: host is the ephemeral container/Pod hostname (socket.gethostname()) and pidns is the container's private /proc/self/ns/pid inode. Once the old container/Pod is removed and replaced (e.g., docker compose up -d recreating loom after .env changes when retire_at_shutdown could not reach ClickHouse, docker kill + container recreation, or a Kubernetes Pod OOMKill/eviction), neither the new container nor the underlying Linux host can ever match host == socket.gethostname() and pidns == my_pidns.
  2. Host crash / reboot (even on bare metal with a stable hostname): A reboot changes /proc/sys/kernel/random/boot_id, so boot != my_boot causes proves_stopped() to return False permanently on the same host.

Because server/cli/participant.py provides no operator break-glass flag and prune_retired only prunes rows already in state = 'retired', the warning persists forever and distributed_drain blocks every future provider reconfiguration unless an operator manually runs DELETE FROM loom._provider_participants against an internal _-prefixed table.

Does it reproduce on the latest release or main?

Yes

How to reproduce
  1. Start Loom using the shipped compose.yaml (COMPOSE_PROFILES=bundled, default LOOM_WEB_WORKERS=2) and wait for /v1/health/ready to return 200.
  2. Confirm active rows in loom._provider_participants (SELECT participant_id, state, host_proof FROM loom._provider_participants FINAL WHERE state != 'retired').
  3. Trigger an unretired container replacement — for example:
    • recreate loom after killing it (docker kill <loom-container> && docker compose up -d --force-recreate loom), or
    • recreate clickhouse and loom together (docker compose up -d --force-recreate clickhouse loom) when loom's retire_at_shutdown loses connectivity to clickhouse before recording retirement.
  4. Wait ~60–90 seconds (STALE_AFTER_S + SWEEP_S) and inspect GET http://127.0.0.1:7777/v1/health:
    • problems reports code: "provider_participants_stale" (heartbeat_expired) for the old container's participant UUIDs.
  5. Attempt the documented fix inside the running loom container (or from the host):
    docker compose exec loom loom participant retire --participant <stale-participant-uuid>
    
    It exits with code 1 even though the old container is completely gone (docker ps -a) and system.processes has 0 queries with loom-participant/<hex>.
Expected behavior

Operators who have verified on the host that the old container/Pod (or pre-reboot OS instance) is physically gone and that all ClickHouse queries for that participant have settled should have a supported way to retire the orphaned participant via loom participant retire without manually mutating loom._provider_participants.

Possible approaches (potentially complementary):

  1. Explicit break-glass CLI flag (e.g., loom participant retire --participant <id> --force-dead / --confirm-host-gone) that still enforces _authority_settled(...) and running_queries(participant, ch=ch) == 0, while allowing an administrator with direct DB credentials to retire an orphaned row whose original pidns or boot_id no longer exists.
  2. Host-level proof for destroyed containers / prior kernel boots: on the same boot_id, a host agent/CLI in the root PID namespace could verify that the recorded Docker/K8s container mount/cgroup (parts[2]) no longer exists; across a reboot on the same stable host identity, a new boot_id proves prior processes of that host have terminated once cross-replica queries settle.
Error message and logs
✗ participant <uuid> has no verifiable exact physical-death proof or its cross-replica queries have not settled; run on its trusted host after the exact process stops. Expiry and Kubernetes object deletion are not proof
Environment
  • Loom version: v1.3.0 (also verified unchanged in main at server/core/provider_process.py and server/cli/participant.py)
  • ClickHouse: 26.x (bundled via compose.yaml, COMPOSE_PROFILES=bundled)
  • OS / Arch: Ubuntu 24.04 LTS (linux/arm64), Docker Compose v2
  • LLM / Embeddings: LOOM_LLM_PROVIDER=fake, local embeddings
Related issues and pull requests

No response

How this was found

An AI tool helped find it, and I reproduced it myself

Additional context

Relevant code paths on main:

  • server/core/provider_process.py: host_proof() and proves_stopped()
  • server/insights/app/provider_barrier.py: retire_at_shutdown(), _retire_dead_row(), retire_participant(), sweep_stopped()
  • server/cli/participant.py: _cmd_retire()
Redaction
  • I removed tokens, keys, passwords and personal or customer data from everything above.
主要语言
Python
星标
221
派生
35
平均合并
14 小时 21 分钟
30 天内合并 PR
873

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

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

ClickHouse/loom 的其他 Issue

查看 ClickHouse/loom 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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