[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
-
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
enhancement good first issue
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 75/100
iceboundrock/AutoForge#304 ·
維護者通常 1 天內回覆
-
enhancement
難度 2/5 1-3 小時 新手友好度 72/100
fossasia/visdom-dev#77 ·
維護者通常 4 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
aws-cloudformation/cfn-lint#4890 ·
維護者通常 2 天內回覆