[Bug] Retried `ActivityHandle.terminate()` can fail after the activity is already terminated
维护者通常 1 天内回复
评估
这个 Issue 还没有评估数据。
描述
What are you really trying to do?
Terminate a standalone activity with ActivityHandle.terminate() and rely on the client's built-in RPC retries.
Describe the bug
_ClientImpl.terminate_activity in temporalio/client/_impl.py builds TerminateActivityExecutionRequest without request_id and sends it with retry=True. The sibling calls (cancel_activity, pause_activity, unpause_activity, start_activity) all set request_id=str(uuid.uuid4()), and the Go SDK sets RequestId on this request too.
On the server, an empty request ID is replaced with a new random one for each attempt (validateAndNormalizeRequestID in chasm/lib/activity/validator.go). Activity.Terminate returns success for a repeat only when the request ID matches the stored one, and otherwise returns NotFound: no running activity execution: it closed with status TERMINATED. So if the first attempt terminates the activity but the response is lost (for example a transient UNAVAILABLE), the automatic retry fails and terminate() raises although the activity was terminated.
Minimal Reproduction
from unittest import mock
import temporalio.api.workflowservice.v1
from temporalio.client import Client
async def main() -> None:
rpc = mock.AsyncMock(
return_value=temporalio.api.workflowservice.v1.TerminateActivityExecutionResponse()
)
service_client = mock.MagicMock()
service_client.config.identity = "test-identity"
service_client.workflow_service.terminate_activity_execution = rpc
client = Client(service_client)
await client.get_activity_handle("my-activity").terminate(reason="done")
print(repr(rpc.call_args.args[0].request_id)) # prints '' on main
Environment/Versions
- SDK:
mainat 600cbec - Python 3.13, Linux x86_64
Additional context
Adding request_id=str(uuid.uuid4()) to the request makes retries of the same call idempotent, matching the other activity operator calls.
- 主要语言
- Python
- 星标
- 1.2k
- 派生
- 269
- 平均合并
- 1 天 11 小时
- 30 天内合并 PR
- 68
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
temporalio/sdk-python 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
temporalio/sdk-python#496 ·
维护者通常 1 天内回复
-
[Bug] Annotated constraints and validators on workflow/activity/handler parameters are ignored by the Pydantic data converter可能已有人在做 @tconley1428 于 1 天前认领。 未关闭bug
temporalio/sdk-python#2006 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Proposal: handle SIGTERM by default to initiate graceful worker shutdown可能已有人在做 @eamsden 于 15 天前认领。 未关闭
temporalio/sdk-python#1948 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Cloud CI Skips Nexus Tests可能重新可做 @tconley1428 于 73 天前认领,目前没有进行中的 PR。 未关闭
temporalio/sdk-python#1704 · 已指派 1 人 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
temporalio/sdk-python#1592 · 8 条评论 ·
维护者通常 1 天内回复
查看 temporalio/sdk-python 的全部 Issue
相似的 Issue
-
难度 1/5 1-3 小时 新手友好度 85/100
WLAN-Pi/wlanpi-profiler#341 ·
维护者通常 1 天内回复
-
Memory leak: the shared `validation_aborted_error` keeps every traceback it is raised through可能已有人在做 @Fire162 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
graphql-python/graphql-core#287 ·
-
难度 2/5 1-3 小时 新手友好度 67/100
roman-corgi/ctc-dip#160 ·
维护者通常 1 天内回复
-
type-bug
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
render_findings.py reads and writes in the host's default encoding, so findings.html breaks on a cp1252 Windows host可能已有人在做 @Aaqibhafeezkhan 今天认领。 未关闭bug good first issue mentored python size: XS up-for-grabs
难度 2/5 1-3 小时 新手友好度 75/100
dheerajjha/mcp-migrate#366 · 1 条评论 ·
维护者通常 1 天内回复