Update sent to an uncached Worker after a command-less first Workflow Task runs before the run method, then fails replay
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 18/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- python
研究方向
Start with _WorkflowInstanceImpl.activate in temporalio/worker/_workflow_instance.py (around lines 484-500 in 1.34.0), which applies update and signal jobs before initialize_workflow, and compare it with the replay path. Run the repro script with max_cached_workflows=0 and then with a large cache to confirm the ordering difference. Done means the run method always executes before the update handler on an uncached worker, and the repro completes without a nondeterminism error.
由索引模型根據 Issue 內容生成。
描述
An update that reaches a Worker without the Workflow in its cache, right after a first Workflow Task that issued no commands, runs its handler before the run method, both live. A later replay runs the run method first. So values from workflow.uuid4() swap between the two, and every later Workflow Task fails with a nondeterminism error.
temporalio 1.34.0, Python 3.13.16, Temporal CLI 1.10.0 (Server 1.32.2), macOS.
import asyncio
import uuid
from datetime import timedelta
from temporalio import activity, workflow
from temporalio.api.enums.v1 import EventType
from temporalio.client import WorkflowUpdateStage
from temporalio.testing import WorkflowEnvironment
from temporalio.worker import Worker
@activity.defn
async def noop() -> None:
pass
@workflow.defn
class UpdateWorkflow:
def __init__(self) -> None:
self.done = False
@workflow.run
async def run(self) -> None:
mode = "replay" if workflow.unsafe.is_replaying() else "live"
print(f"run method ({mode}):", workflow.uuid4(), flush=True)
await workflow.wait_condition(lambda: self.done)
@workflow.update
async def update(self) -> None:
mode = "replay" if workflow.unsafe.is_replaying() else "live"
activity_id = f"act-{workflow.uuid4()}"
print(f"update ({mode}):", activity_id, flush=True)
await workflow.execute_activity(
noop, activity_id=activity_id, start_to_close_timeout=timedelta(seconds=10)
)
self.done = True
async def main() -> None:
async with await WorkflowEnvironment.start_local(dev_server_log_level="error") as env:
async with Worker(
env.client,
task_queue="q",
workflows=[UpdateWorkflow],
activities=[noop],
max_cached_workflows=0,
):
handle = await env.client.start_workflow(
UpdateWorkflow.run, id=str(uuid.uuid4()), task_queue="q"
)
# Wait until the first Workflow Task, which has no commands, completes.
while not any(
e.event_type == EventType.EVENT_TYPE_WORKFLOW_TASK_COMPLETED
for e in (await handle.fetch_history()).events
):
await asyncio.sleep(0.1)
await handle.start_update(
UpdateWorkflow.update, wait_for_stage=WorkflowUpdateStage.ACCEPTED
)
try:
await asyncio.wait_for(handle.result(), 10)
print("completed")
except asyncio.TimeoutError:
for e in (await handle.fetch_history()).events:
if e.event_type == EventType.EVENT_TYPE_WORKFLOW_TASK_FAILED:
print("task failed:", e.workflow_task_failed_event_attributes.failure.message)
break
await handle.terminate()
if __name__ == "__main__":
asyncio.run(main())
Output of python repro.py 2>/dev/null | grep -E '^(run method|update|task failed|completed)':
run method (live): d2101c6b-5154-42d0-9d93-90790dce80d8
update (live): act-d2101c6b-5154-42d0-9d93-90790dce80d8
run method (live): fe143ce3-789d-406b-97bb-ee4e6ddb64ab
run method (replay): d2101c6b-5154-42d0-9d93-90790dce80d8
update (replay): act-fe143ce3-789d-406b-97bb-ee4e6ddb64ab
run method (replay): d2101c6b-5154-42d0-9d93-90790dce80d8
update (replay): act-fe143ce3-789d-406b-97bb-ee4e6ddb64ab
task failed: [TMPRL1100] Nondeterminism error: Activity id of scheduled event 'act-d2101c6b-5154-42d0-9d93-90790dce80d8' does not match activity id of activity command 'act-fe143ce3-789d-406b-97bb-ee4e6ddb64ab'
- Line 1: the first Workflow Task runs the run method, which draws
d2101c6b-…and waits. It issues no commands. - Lines 2 and 3: the update's task, on a cache of 0, runs the update handler first, live, so it draws
d2101c6b-…, then runs the run method again, also live. - From line 4: each later task replays the run method first, so the handler draws
fe143ce3-…and its Activity ID no longer matches history.
With max_cached_workflows=1000, the same script prints:
run method (live): 12225546-2e7a-4fbc-8a12-dea82961db18
update (live): act-70f81baf-de7d-47d4-ba6c-8ffa093f1a15
completed
_WorkflowInstanceImpl.activate (temporalio/worker/_workflow_instance.py, lines 484-500 in 1.34.0) applies signal and update jobs before initialize_workflow. That suits signal-with-start, but here the run method already ran in an earlier task. It may be that the first task should be replayed on its own instead.
Found while reviewing temporalio/ai-integrations#133, where the LangSmith plugin's run IDs depend on the same order.
- 主要語言
- Python
- 星號
- 1.2k
- 分支
- 285
- 平均合併
- 1 天 23 小時
- 30 天內合併 PR
- 80
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
temporalio/sdk-python 的其他 Issue
-
[Bug] Deadlock interruption can leak a logging.Handler lock on Python ≤ 3.12 and freeze the worker未關閉
難度 4/5 3-5 天 新手友好度 47/100
temporalio/sdk-python#2095 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 58/100
temporalio/sdk-python#2092 ·
維護者通常 1 天內回覆
-
[Bug] Sandboxed datetime hints can fail decoding and drop signals可能已有人在做 @VegetarianOrc 於 3 天前認領。 未關閉sdk-python
temporalio/sdk-python#2072 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
[Bug] TaskGroup cancellation of mixed Temporal operations can break replay可能已有人在做 @VegetarianOrc 於 3 天前認領。 未關閉sdk-python
temporalio/sdk-python#2069 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
sdk-python
難度 4/5 3-5 天 新手友好度 22/100
temporalio/sdk-python#2067 · 2 則留言 ·
維護者通常 1 天內回覆
查看 temporalio/sdk-python 的全部 Issue
相似的 Issue
-
Remove the `pull_request_target` workflow before GitHub blocks it可能已有人在做 @jat255 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 85/100
IBM/mcp-context-forge#7483 ·
維護者通常 2 天內回覆
-
bug good first issue
難度 2/5 1-3 小時 新手友好度 78/100
-
[Bug Report]: OpenAI 辅助 API 连通性测试因输出上限仅 1 token 误报“未知错误”可能已有人在做 @fjfanjian 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
Project-N-E-K-O/N.E.K.O#3640 ·
維護者通常 1 天內回覆
-
author-page correction
難度 2/5 1-3 小時 新手友好度 64/100
acl-org/acl-anthology#10808 · 1 則留言 ·
維護者通常 1 天內回覆