Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Bug] Dropping any client stops log forwarding for every other client of the same Runtime

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

维护者通常 1 天内回复

@parbhatkapila4 已经在做这个了。

开始于 2026年10月21日。

  • #1998 来自 @parbhatkapila4 —— 未关闭

评估

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

调研方向

Start in temporalio/bridge/src/runtime.rs and trace how cloned Runtime values manage log_forwarder_handle during Drop; compare that ownership with the clone created in client.rs. Check the runtime and log forwarding tests for existing lifecycle coverage. Done means dropping one client no longer stops forwarded logs for clients still using the shared runtime, while forwarding stops when the runtime is no longer owned.

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

描述

What are you really trying to do?

Forward core logs to a Python logger with LogForwardingConfig, on a Runtime that several clients share. Some clients are short-lived (made for one call and dropped), and one is kept for a worker.

Describe the bug

When any client of a Runtime is dropped, log forwarding stops for every other client of that runtime, for the rest of the process. No error or warning is shown: the forwarded logger just receives nothing more.

The cause appears to be in temporalio/bridge/src/runtime.rs (same on main and in 1.34.0):

  • Runtime is #[derive(Clone)], and each client keeps a clone of it (client.rs: let runtime = runtime_ref.runtime.clone();).
  • log_forwarder_handle: Option<Arc<JoinHandle<()>>> is shared by every clone.
  • impl Drop for Runtime calls handle.abort() on that shared handle.

So the first clone to drop, which is the first client garbage-collected, aborts the forwarder that the RuntimeRef and every remaining client still rely on.

A possible fix: abort the forwarder only when the last owner goes away. For example, wrap the JoinHandle in a small type that aborts in its own Drop, and keep that type behind the Arc. Or implement Drop on RuntimeRef only.

Minimal Reproduction

Against a local dev server (temporal server start-dev):

"""Dropping one client of a Runtime stops log forwarding for every other client of that Runtime."""
import asyncio, gc, logging, sys, uuid
from datetime import timedelta
from temporalio import workflow
from temporalio.client import Client
from temporalio.runtime import LogForwardingConfig, LoggingConfig, Runtime, TelemetryConfig, TelemetryFilter
from temporalio.worker import Worker

@workflow.defn
class Noop:
    @workflow.run
    async def run(self) -> None:
        return None

class Count(logging.Handler):
    def __init__(self): super().__init__(); self.n = 0
    def emit(self, record): self.n += 1

async def main(drop_one: bool) -> int:
    handler = Count()
    logger = logging.getLogger(f"forwarded-{uuid.uuid4()}")
    logger.addHandler(handler); logger.setLevel(logging.DEBUG); logger.propagate = False
    runtime = Runtime(telemetry=TelemetryConfig(logging=LoggingConfig(
        filter=TelemetryFilter(core_level="INFO", other_level="WARN"),
        forwarding=LogForwardingConfig(logger=logger))))
    kept = await Client.connect("localhost:7233", runtime=runtime)
    if drop_one:
        other = await Client.connect("localhost:7233", runtime=runtime)
        del other
        gc.collect()
    async with Worker(kept, task_queue=f"q-{uuid.uuid4()}", workflows=[Noop]):
        await asyncio.sleep(3)
    await asyncio.sleep(1)
    return handler.n

if __name__ == "__main__":
    drop = sys.argv[1] == "drop"
    print(("drop one client" if drop else "keep every client"), "->", asyncio.run(main(drop)), "core records forwarded")

Output, run twice each (temporalio 1.32.0, CPython 3.13, macOS arm64):

keep every client -> 2 core records forwarded
drop one client -> 0 core records forwarded
keep every client -> 4 core records forwarded
drop one client -> 0 core records forwarded

The only difference between the two runs is a second client made on the same runtime and dropped before the worker starts. In a longer test, a worker kept alive for 25 s forwarded 18 core records. The same worker after one short-lived client on its runtime was dropped forwarded none. Eight clients kept alive forwarded 15; the same eight dropped forwarded 0.

The workaround is one Runtime per client. It costs a thread per CPU for each runtime.

Environment/Versions

  • OS and processor: macOS, Apple Silicon
  • Temporal version: Python SDK 1.32.0 reproduced; the same code is in runtime.rs in 1.34.0 and on main
  • Server: temporal server start-dev (Temporal CLI)
主要语言
Python
星标
1.2k
派生
269
平均合并
1 天 20 小时
30 天内合并 PR
60

环境准备

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

从这里开始

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

temporalio/sdk-python 的其他 Issue

查看 temporalio/sdk-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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